Posted: 23 Nov 2006, 14:11
obsolete
Open Source Realtime Strategy Game Engine
https://springrts.com/phpbb/
Code: Select all
#include <ctime>
#include <iostream>
#include <vector>
int count_primes(unsigned int maxprime) {
std::vector<bool> prime(maxprime, true);
unsigned int count = 0;
for (unsigned int i = 2; i < maxprime; ++i) {
if (!prime[i]) continue;
++count;
for (unsigned int j = i * 2; j < maxprime; j += i) prime[j] = false;
}
return count;
}
int main() {
using std::cout;
using std::endl;
clock_t start = clock();
cout << "number of primes: " << count_primes(10000000) << endl;
clock_t finish = clock();
double time = double(finish - start) / CLOCKS_PER_SEC;
cout << "elapsed time: " << time << endl;
}
Code: Select all
H:\dev\test\testperf>primecs
number of primes: 664579
elapsed time: 2.4375
H:\dev\test\testperf>primevectormingwo2
number of primes: 664579
elapsed time: 1.75
Code: Select all
H:\dev\test\testperf>primecs
number of primes: 664579
elapsed time: 1.3125
http://www.novell.com/linux/microsoft/openletter.html# Mono, OpenOffice and Samba
* Under the patent agreement, customers will receive coverage for Mono, Samba, and OpenOffice as well as .NET and Windows Server.
* All of these technologies will be improved upon during the 5 years of the agreement and there are some limits on the coverage that would be provided for future technologies added to these offerings.
* The collaboration framework we have put in place allows us to work on complex subjects such as this where intellectual property and innovation are important parts of the conversation.
* Novell customers can use these technologies, secure in the knowledge that Microsoft and Novell are working together to offer the best possible joint solution.
Code: Select all
void RenderUnitPartDirect(UnitPart unitpart)
{
Gl.glBegin(Gl.GL_TRIANGLES);
foreach (Primitive primitive in unitpart.Primitives)
{
Triangle triangle = primitive as Triangle;
Vertex(triangle.Vertices[0].Pos);
Vertex(triangle.Vertices[1].Pos);
Vertex(triangle.Vertices[2].Pos);
}
Gl.glEnd();
}
void RenderUnitPartvbo(UnitPart unitpart)
{
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
GlCheckError();
Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, unitvbo);
GlCheckError();
Gl.glVertexPointer(3, Gl.GL_FLOAT, 0, IntPtr.Zero);
GlCheckError();
Gl.glDrawArrays(Gl.GL_TRIANGLES, 0, numunitvertices );
Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
}
void RenderUnitPartVa(UnitPart unitpart)
{
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
GlCheckError();
Gl.glVertexPointer(3, Gl.GL_FLOAT, 0, vertexarray);
GlCheckError();
Gl.glDrawArrays(Gl.GL_TRIANGLES, 0, numunitvertices );
Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
}
void RenderUnitPart(UnitPart unitpart)
{
switch (rendertype)
{
case RenderTypeEnum.Direct:
RenderUnitPartDirect(unitpart);
break;
case RenderTypeEnum.Va:
RenderUnitPartVa(unitpart);
break;
case RenderTypeEnum.Vbo:
RenderUnitPartvbo(unitpart);
break;
}
}
enum RenderTypeEnum
{
Vbo,
Va,
Direct
}
RenderTypeEnum rendertype = RenderTypeEnum.Direct;
Code: Select all
for (int x = 0; x < 100; x++)
{
RenderUnitPart(unit.unitpart);
Gl.glTranslated(10, 0, 0);
}
How do you figure that? If the VBO's are in (relatively slow) system memory then there's the additional constant overhead of transferring them to the (also-slow) GPU so you gain very little wrt rendering time, especially if they are large. Thus I think comparing VBO performance to immediate-mode rendertime is a bit skewed in this case, considering the compiler probably also optimizes those glVertex calls since they're all going into the same unmanaged code section anyway.This can be explained by the dev machine's having an onboard graphics card, so VBO memory is probably system memory. This isnt important to the test.
Note that this was compiled in debug mode -> no compile-time optimization.Kloot wrote:the compiler probably also optimizes those glVertex calls since they're all going into the same unmanaged code section anyway.
Code: Select all
H:\bin\java\jogl-1_0_0-windows-i586\jogl-1_0_0-windows-i586\lib>java Test
after show
0 fps 44232 triangles per frame
8 fps 44232 triangles per frame
8 fps 44232 triangles per frame
10 fps 44232 triangles per frame
8 fps 44232 triangles per frame
8 fps 44232 triangles per frame
10 fps 44232 triangles per frame
9 fps 44232 triangles per frame
8 fps 44232 triangles per frame
10 fps 44232 triangles per frame
8 fps 44232 triangles per frame
12 fps 44232 triangles per frame
13 fps 44232 triangles per frame
13 fps 44232 triangles per frame
12 fps 44232 triangles per frame
16 fps 44232 triangles per frame
13 fps 44232 triangles per frame
19 fps 44232 triangles per frame
19 fps 44232 triangles per frame
14 fps 44232 triangles per frame
16 fps 44232 triangles per frame
14 fps 44232 triangles per frame
16 fps 44232 triangles per frame
12 fps 44232 triangles per frame
8 fps 44232 triangles per frame
8 fps 44232 triangles per frame
8 fps 44232 triangles per frame
9 fps 44232 triangles per frame
8 fps 44232 triangles per frame
10 fps 44232 triangles per frame
8 fps 44232 triangles per frame
8 fps 44232 triangles per frame
8 fps 44232 triangles per frame
8 fps 44232 triangles per frame
Code: Select all
H:\bin\java\jogl-1_0_0-windows-i586\jogl-1_0_0-windows-i586\lib>test
requested window width/height: 500 500
15 fps 44232 triangles per frame
14 fps 44232 triangles per frame
14 fps 44232 triangles per frame
14 fps 44232 triangles per frame
14 fps 44232 triangles per frame
15 fps 44232 triangles per frame
22 fps 44232 triangles per frame
29 fps 44232 triangles per frame
30 fps 44232 triangles per frame
31 fps 44232 triangles per frame
39 fps 44232 triangles per frame
31 fps 44232 triangles per frame
13 fps 44232 triangles per frame
11 fps 44232 triangles per frame
12 fps 44232 triangles per frame
11 fps 44232 triangles per frame
10 fps 44232 triangles per frame
12 fps 44232 triangles per frame
14 fps 44232 triangles per frame
14 fps 44232 triangles per frame
15 fps 44232 triangles per frame
13 fps 44232 triangles per frame
12 fps 44232 triangles per frame
14 fps 44232 triangles per frame
12 fps 44232 triangles per frame
11 fps 44232 triangles per frame
14 fps 44232 triangles per frame
26 fps 44232 triangles per frame
39 fps 44232 triangles per frame
29 fps 44232 triangles per frame
32 fps 44232 triangles per frame
38 fps 44232 triangles per frame
17 fps 44232 triangles per frame
12 fps 44232 triangles per frame
Code: Select all
numtrisperframe = 0;
double radiusstep = 0.01;
for( double radius = 0.1; radius < 3; radius += radiusstep )
{
gl.glBegin( GL.GL_QUADS );
double step = Math.PI * 2 / 100;
for( double angle = 0; angle <= Math.PI * 2 * 0.75; angle+= step )
{
double x = radius * Math.sin( angle );
double y = radius * Math.cos( angle );
gl.glVertex3d( x,y,0);
x = ( radius + radiusstep ) * Math.sin( angle );
y = ( radius + radiusstep ) * Math.cos( angle );
gl.glVertex3d( x,y,0);
x = ( radius + radiusstep ) * Math.sin( angle + step );
y = ( radius + radiusstep ) * Math.cos( angle + step );
gl.glVertex3d( x,y,0);
x = radius * Math.sin( angle + step );
y = radius * Math.cos( angle + step );
gl.glVertex3d( x,y,0);
numtrisperframe += 2;
}
gl.glEnd();
}