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();
watch.Start();
}
count++;
void Stats::Start() {
tri = extr = 0;
watch.Start();
}
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();
@ -185,13 +198,27 @@ void NexusMt::Render(Extraction &extraction, DrawContest &contest,
glDisableClientState(GL_NORMAL_ARRAY);
}
void NexusMt::Draw(unsigned int cell, DrawContest &contest) {
void NexusMt::Draw(unsigned int cell, DrawContest &contest) {
static ::GLUquadricObj * spr = gluNewQuadric();
Entry &entry = operator[](cell);
Patch &patch = *(entry.patch);
char *fstart;
char *vstart;
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)
@ -215,7 +242,9 @@ void NexusMt::Draw(unsigned int cell, DrawContest &contest) {
if(contest.attrs & DrawContest::COLOR)
glColorPointer(4, GL_UNSIGNED_BYTE, 0, cstart);
if(contest.attrs & DrawContest::NORMAL)
glNormalPointer(GL_SHORT, 8, nstart);
glNormalPointer(GL_SHORT, 8, nstart);
switch(contest.mode) {
case DrawContest::POINTS:

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
@ -242,13 +245,16 @@ int main(int argc, char *argv[]) {
if(argc < 2) {
cerr << "Usage: " << argv[0] << " <nexus file> [options]\n";
cerr << "-e <error>: set initial target error\n"
<< "-m <ram>: max ram used\n"
<< "-x <ram>: max extraction size\n"
<< "-r <ram>: max draw size\n"
<< "-d <ram>: max disk read per frame\n"
<< "-p : no preload\n"
<< "-o namefile: ouput stats";
cerr << "-e <error> : set initial target error\n"
<< "-m <ram> : max ram used\n"
<< "-x <ram> : max extraction size\n"
<< "-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) {
@ -491,7 +499,7 @@ int main(int argc, char *argv[]) {
float r = nexus.sphere.Radius();
glColor3f(0.8f, 0.8f, 0.8f);
if(extract) {
extraction.frustum.GetView();
extraction.metric->GetView();
@ -501,11 +509,13 @@ int main(int argc, char *argv[]) {
extraction.Update(&nexus);
}
}
if(do_render)
nexus.Render(extraction, contest, &stats);
else
stats.Init();
stats.Stop();
stats.Start();
if(do_render)
nexus.Render(extraction, contest, &stats);
/* if(show_borders) {
for(unsigned int i = 0; i < cells.size(); i++) {
Border &border = nexus.GetBorder(cells[i]);
@ -525,7 +535,7 @@ int main(int argc, char *argv[]) {
tframe.push_front(watch.Time());
if(tframe.size() > tlen) tframe.pop_back();
terror.push_front(extraction.max_error);
if(terror.size() > tlen) terror.pop_back();
@ -541,39 +551,42 @@ 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);
glColor4f(0.6f, 0.6f, 0.6f, 0.5f);
glBegin(GL_LINE_STRIP);
for(unsigned int i = 0; i < tframe.size() -1; i++) {
double diff = (tframe[i] - tframe[i+1]);
//glVertex2f(i/1024.0f,0);
glVertex2f(i/1024.0f,2*diff);
glBegin(GL_LINE_STRIP);
for(unsigned int i = 0; i < tframe.size() -1; i++) {
double diff = (tframe[i] - tframe[i+1]);
//glVertex2f(i/1024.0f,0);
glVertex2f(i/1024.0f,2*diff);
}
glEnd();
glColor4f(0.0f, 0.6f, 0.2f, 0.5f);
glBegin(GL_LINE_STRIP);
for(unsigned int i = 0; i < terror.size() -1; i++) {
// glVertex2f(i/1024.0f,0);
glVertex2f(i/1024.0f,terror[i]/300);
}
glEnd();
}
glEnd();
glColor4f(0.0f, 0.6f, 0.2f, 0.5f);
glBegin(GL_LINE_STRIP);
for(unsigned int i = 0; i < terror.size() -1; i++) {
// glVertex2f(i/1024.0f,0);
glVertex2f(i/1024.0f,terror[i]/300);
}
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));
gl_print(0.03, 0.15, buffer);
sprintf(buffer, "Extr size: %.2f / %.2f Mb",
extraction.extr_used * nexus.chunk_size/(float)(1<<20),
extraction.extr_max * nexus.chunk_size/(float)(1<<20));
gl_print(0.03, 0.12, buffer);
sprintf(buffer, "Draw size: %.2f / %.2f Mb",
extraction.draw_used * nexus.chunk_size/(float)(1<<20),
extraction.draw_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);
@ -595,50 +608,53 @@ int main(int argc, char *argv[]) {
glPopMatrix();
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 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"
static Stats statsAcc;
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"
<< 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.fps/(float)statsAcc.count) << "\t"
// << (statsAcc.kdisk/(float)statsAcc.count) << "\t"
<< ram_used /(float)statsAcc.count * nexus.chunk_size/(float)(1<<20) << "\t"
<< extr_used/(float)statsAcc.count * nexus.chunk_size/(float)(1<<20) << "\t"
<< draw_used/(float)statsAcc.count * nexus.chunk_size/(float)(1<<20) << "\t"
<< disk_used/(float)statsAcc.count * nexus.chunk_size/(float)(1<<20) << "\t"
<< "\n";
statsAcc.Init();
statsAcc.count=0;
statsAcc.fps=0;
ram_used = extr_used= draw_used = disk_used=0.0;
}
else{
statsAcc.fps+=stats.fps;
statsAcc.kdisk+=stats.kdisk;
statsAcc.ktri+=stats.ktri;
<< 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.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"
<< extr_used/(float)statsAcc.count*nexus.chunk_size/(float)(1<<20) << "\t"
<< draw_used/(float)statsAcc.count*nexus.chunk_size/(float)(1<<20) << "\t"
<< disk_used/(float)statsAcc.count*nexus.chunk_size/(float)(1<<20) << "\t"
<< "\n";
statsAcc.Init();
statsAcc.count = 0;
statsAcc.fps = 0;
ram_used = extr_used = draw_used = disk_used = 0.0;
} else {
statsAcc.fps += stats.fps;
statsAcc.kdisk += stats.kdisk;
statsAcc.ktri += stats.ktri;
ram_used +=nexus.ram_used;
extr_used+=extraction.extr_used;
draw_used+=extraction.draw_used;
disk_used+=extraction.disk_used;
}
}
ram_used += nexus.ram_used;
extr_used += extraction.extr_used;
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();