Reorderes statistics a bit.

This commit is contained in:
Federico Ponchio 2005-02-17 15:39:44 +00:00
parent 12258dcd25
commit 5fb9d84548
5 changed files with 185 additions and 111 deletions

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.29 2005/02/14 17:11:07 ponchio
aggiunta delle sphere
Revision 1.28 2005/02/08 12:43:03 ponchio
Added copyright
@ -47,15 +50,25 @@ using namespace nxs;
using namespace vcg;
using namespace std;
void Stats::Init() {
ktri = 0;
kdisk = 0;
if(count == 25) count = 0;
if(!count) {
fps = 25/watch.Time();
void Stats::Start() {
tri = extr = 0;
watch.Start();
}
count++;
void Stats::Disk(float _disk) {
disk.push_front(_disk);
if(disk.size() > log_size) disk.pop_back();
}
void Stats::Error(float _error) {
error.push_front(_error);
if(error.size() > log_size) error.pop_back();
}
void Stats::Stop() {
time.push_front((float)watch.Time());
if(time.size() > log_size) time.pop_back();
fps = (7*fps + 1/time[0])/8.0f;
}
NexusMt::NexusMt() {
@ -117,7 +130,6 @@ void NexusMt::Render(DrawContest contest) {
void NexusMt::Render(Extraction &extraction, DrawContest &contest,
Stats *stats) {
static ::GLUquadricObj * spr = gluNewQuadric();
if(stats) stats->Init();
for(unsigned int i = 0; i < heap.size(); i++) {
Item &item = heap[i];
@ -142,20 +154,13 @@ void NexusMt::Render(Extraction &extraction, DrawContest &contest,
unsigned int patch = extraction.selected[i].id;
Entry &entry = operator[](patch);
vcg::Sphere3f &sphere = entry.sphere;
if(stats) stats->extr += entry.nface;
if(extraction.frustum.IsOutside(sphere.Center(), sphere.Radius()))
continue;
if(contest.attrs & DrawContest::SPHERES){
glPushAttrib(GL_POLYGON_BIT);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glPushMatrix();
glTranslatef(sphere.Center().X(),sphere.Center().Y(),sphere.Center().Z());
gluSphere(spr,sphere.Radius(),15,15);
glPopMatrix();
glPopAttrib();
}
if(stats) stats->ktri += entry.nface;
if(stats) stats->tri += entry.nface;
if(!entry.patch) {
skipped.push_back(extraction.selected[i]);
@ -168,13 +173,21 @@ void NexusMt::Render(Extraction &extraction, DrawContest &contest,
preload.trigger.reset();
preload.lock.enter();
if(skipped.size()) cerr << "Skipped: " << skipped.size() << endl;
// if(skipped.size()) cerr << "Skipped: " << skipped.size() << endl;
for(vector<Item>::iterator i = skipped.begin(); i != skipped.end(); i++) {
GetPatch((*i).id, (*i).error);
Draw((*i).id, contest);
}
Flush(false); //in case there are no skipped... :P
if(stats) {
stats->Error(extraction.max_error);
stats->Disk(preload.disk);
preload.disk = 0;
}
preload.trigger.post();
preload.lock.leave();
@ -186,6 +199,8 @@ void NexusMt::Render(Extraction &extraction, DrawContest &contest,
}
void NexusMt::Draw(unsigned int cell, DrawContest &contest) {
static ::GLUquadricObj * spr = gluNewQuadric();
Entry &entry = operator[](cell);
Patch &patch = *(entry.patch);
char *fstart;
@ -193,6 +208,18 @@ void NexusMt::Draw(unsigned int cell, DrawContest &contest) {
char *cstart;
char *nstart;
if(contest.attrs & DrawContest::SPHERES){
vcg::Sphere3f &sphere = entry.sphere;
glPushAttrib(GL_POLYGON_BIT);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glPushMatrix();
glTranslatef(sphere.Center().X(),sphere.Center().Y(),sphere.Center().Z());
gluSphere(spr,sphere.Radius(),15,15);
glPopMatrix();
glPopAttrib();
}
if(use_vbo) {
if(!entry.vbo_element)
LoadVbo(entry);
@ -217,6 +244,8 @@ void NexusMt::Draw(unsigned int cell, DrawContest &contest) {
if(contest.attrs & DrawContest::NORMAL)
glNormalPointer(GL_SHORT, 8, nstart);
switch(contest.mode) {
case DrawContest::POINTS:
glDrawArrays(GL_POINTS, 0, patch.nv); break;

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.23 2005/02/14 17:11:07 ponchio
aggiunta delle sphere
Revision 1.22 2005/02/10 09:18:20 ponchio
Statistics.
@ -63,20 +66,25 @@ namespace nxs {
};
struct Stats {
float ktri; //k triangles rendered.
float kdisk; //k readed per frame (mean)
float kdisk_peak; //k readed peak.
float fps;
float fps_peak; //low fps peaks
//per frame data...
float tri; //k triangles rendered.
float extr; //k triangles extracted
float error; //max error in extraction
//double last_time;
unsigned int count;
int log_size;
deque<float> error; //max error in extraction (push_front pop_back)
deque<float> time;
deque<float> disk; //kdisk readed per frame
float fps; //averaged over 8 frames
Watch watch;
Stats(): count(0) {}
void Init();
Stats(): log_size(48), fps(0.0f) {}
void Start();
void Disk(float disk);
void Error(float error);
void Stop();
};
class NexusMt: public Nexus {

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.39 2005/02/17 14:02:03 ponchio
Full screen options...
Revision 1.38 2005/02/16 15:52:09 ponchio
qualche opzione in piu' , tolti i grafici
@ -248,6 +251,9 @@ int main(int argc, char *argv[]) {
<< "-r <ram> : max draw size\n"
<< "-d <ram> : max disk read per frame\n"
<< "-p : no preload\n"
<< "-w <pixels>: window width\n"
<< "-h <pixels>: window height\n"
<< "-f : fullscreen mode\n"
<< "-o namefile: ouput stats";
return -1;
}
@ -262,7 +268,7 @@ int main(int argc, char *argv[]) {
Extraction extraction;
DrawContest contest;
Stats stats;
stats.Start();
bool rotate = false;
@ -274,11 +280,13 @@ int main(int argc, char *argv[]) {
bool extract = true;
bool realtime = true;
bool preload = true;
bool step = true;
bool output_stats = false;
char output_filename[100];
char window_name [100];
sprintf(window_name,"%s", argv[1]);
int option;
while((option = getopt(argc, argv, "e:m:x:r:d:o:w:h:p:f")) != EOF) {
switch(option) {
@ -501,10 +509,12 @@ int main(int argc, char *argv[]) {
extraction.Update(&nexus);
}
}
stats.Stop();
stats.Start();
if(do_render)
nexus.Render(extraction, contest, &stats);
else
stats.Init();
/* if(show_borders) {
for(unsigned int i = 0; i < cells.size(); i++) {
@ -541,7 +551,8 @@ int main(int argc, char *argv[]) {
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
char buffer[1024];
//show frame and error graphics
if(false){
glColor4f(0.6f, 0.6f, 0.6f, 0.5f);
@ -562,8 +573,10 @@ int main(int argc, char *argv[]) {
}
glEnd();
}
glColor3f(1.0f, 1.0f, 1.0f);
char buffer[1024];
sprintf(buffer, "Ram size : %.2f / %.2f Mb",
nexus.ram_used * nexus.chunk_size/(float)(1<<20),
nexus.ram_max * nexus.chunk_size/(float)(1<<20));
@ -585,8 +598,8 @@ int main(int argc, char *argv[]) {
gl_print(0.03, 0.06, buffer);
sprintf(buffer, "%.2f KTri %.2f FPS %.0f M/s",
stats.ktri/(float)(1<<10),
stats.fps, stats.fps * stats.ktri/(float)(1<<20));
stats.tri/(float)(1<<10),
stats.fps, stats.fps * stats.tri/(float)(1<<20));
gl_print(0.03, 0.03, buffer);
@ -596,25 +609,30 @@ int main(int argc, char *argv[]) {
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
/* statistics: output on file
if(output_stats){
// statistics: output on file
static Stats statsAcc;
static float ram_used ,float extr_used, float draw_used ,float disk_used;
static float ram_used;
static float extr_used;
static float draw_used;
static float disk_used;
static std::ofstream outf(output_filename);
static bool first=true;
if(first) {
outf<< "ktri\t fps\t ram \t extr \t draw \t disk \n"
<< " \t \t" << nexus.ram_max * nexus.chunk_size/(float)(1<<20) << "\t"
<< " \t \t"
<< nexus.ram_max * nexus.chunk_size/(float)(1<<20) << "\t"
<< extraction.extr_max * nexus.chunk_size/(float)(1<<20) << "\t"
<< extraction.draw_max * nexus.chunk_size/(float)(1<<20)<<"\t"
<< extraction.disk_max * nexus.chunk_size/(float)(1<<20)<< "\n";
first = false;
}
statsAcc.count++ ;
if((statsAcc.count%30)==0) {
outf
<< (statsAcc.ktri/(float)statsAcc.count)/(float)(1<<10) << "\t"
<< (statsAcc.tri/(float)statsAcc.count)/(float)(1<<10) << "\t"
<< (statsAcc.fps/(float)statsAcc.count) << "\t"
// << (statsAcc.kdisk/(float)statsAcc.count) << "\t"
<< ram_used/(float)statsAcc.count*nexus.chunk_size/(float)(1<<20) << "\t"
@ -626,8 +644,7 @@ int main(int argc, char *argv[]) {
statsAcc.count = 0;
statsAcc.fps = 0;
ram_used = extr_used = draw_used = disk_used = 0.0;
}
else{
} else {
statsAcc.fps += stats.fps;
statsAcc.kdisk += stats.kdisk;
statsAcc.ktri += stats.ktri;
@ -637,8 +654,7 @@ int main(int argc, char *argv[]) {
draw_used += extraction.draw_used;
disk_used += extraction.disk_used;
}
}
}*/
}
SDL_GL_SwapBuffers();

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.6 2005/02/08 12:43:03 ponchio
Added copyright
****************************************************************************/
@ -35,6 +38,10 @@ using namespace std;
using namespace nxs;
void Preload::execute() {
total_disk = 0;
disk = 0;
assert(mt);
while(!get_signaled()) {
trigger.wait();
@ -51,7 +58,16 @@ using namespace nxs;
if(item.error == 0 || mt->CanAdd(item)) {
//we cannot flush since we are not in the openGL thread
//and flushing includes VBO buffer flushing also.
mt->GetPatch(item.id, item.error, false);
Entry &entry = (*mt)[item.id];
if(!entry.patch)
disk += entry.disk_size;
Patch &patch = mt->GetPatch(item.id, item.error, false);
//test... make sure memory is in ram (if not on vbo that is.
if(!entry.vbo_array)
total_disk += patch.Face(0)[0];
queue.pop_back();
} else
queue.clear();

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.4 2005/02/08 12:43:03 ponchio
Added copyright
****************************************************************************/
@ -52,6 +55,8 @@ class Preload: public pt::thread{
std::vector<Item> queue;
unsigned int disk; //kbytes readed from disk
unsigned int total_disk;
Preload(): thread(false), trigger(false, false) {}
~Preload() {
waitfor();