Added statistics.

This commit is contained in:
Federico Ponchio 2004-10-14 13:46:34 +00:00
parent c65e4840b1
commit 54a1d90730
3 changed files with 44 additions and 8 deletions

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.12 2004/10/09 14:46:47 ponchio
Windows porting small changes.
Revision 1.11 2004/10/04 16:49:54 ponchio
Daily backup. Preparing for compression.
@ -91,6 +94,7 @@ using namespace std;
#include <wrap/gui/trackball.h>
#include "stopwatch.h"
using namespace vcg;
@ -152,8 +156,7 @@ int main(int argc, char *argv[]) {
// int option;
if(argc != 2) {
cerr << "Usage: " << argv[0] << " <nexus file>\n";
return -1;
cerr << "Usage: " << argv[0] << " <nexus file>\n"; return -1;
}
NexusMt nexus;
@ -175,19 +178,25 @@ int main(int argc, char *argv[]) {
" s: screen error extraction\n"
" g: geometry error extraction\n"
" p: draw points\n"
" t: show statistics\n"
" r: toggle realtime mode (TODO)\n"
" b: increase memory buffer\n"
" B: decrease memory buffer\n"
" d: debug mode (show patches colored)\n"
" m: smooth mode\n"
" c: show colors\n"
" n: show normals\n"
" r: rotate model\n"
" u: rotate model\n"
" -: decrease error\n"
" +: increase error (= too)\n";
StopWatch watch;
bool rotate = false;
bool show_borders = true;
bool show_colors = true;
bool show_normals = true;
bool show_statistics = true;
NexusMt::Mode mode = NexusMt::SMOOTH;
NexusMt::PolicyKind policy = NexusMt::FRUSTUM;
@ -218,6 +227,8 @@ int main(int argc, char *argv[]) {
case SDLK_b: show_borders = !show_borders; break;
case SDLK_c: show_colors = !show_colors; break;
case SDLK_n: show_normals = !show_normals; break;
case SDLK_9: nexus.patches.ram_size *= 0.8; break;
case SDLK_0: nexus.patches.ram_size *= 1.2; break;
case SDLK_s: policy = NexusMt::FRUSTUM; break;
case SDLK_p: mode = NexusMt::POINTS; break;
@ -227,12 +238,10 @@ int main(int argc, char *argv[]) {
case SDLK_r:
case SDLK_SPACE: rotate = !rotate; break;
case SDLK_MINUS: error *= 0.9f;
cerr << "error: " << error << endl; break;
case SDLK_MINUS: error *= 0.9f; break;
case SDLK_EQUALS:
case SDLK_PLUS: error *= 1.1f;
cerr << "error: " << error << endl; break;
case SDLK_PLUS: error *= 1.1f; break;
}
break;
case SDL_KEYUP:
@ -315,7 +324,21 @@ int main(int argc, char *argv[]) {
nexus.SetComponent(NexusMt::COLOR, show_colors);
nexus.SetComponent(NexusMt::NORMAL, show_normals);
watch.Restart();
nexus.Render();
if(show_statistics) {
cerr << "Error: " << error << endl;
cerr << "Ram used: " << nexus.patches.ram_used << endl;
cerr << "Ram size: " << nexus.patches.ram_size << endl;
cerr << "Ram flushed: " << nexus.patches.ram_flushed << endl;
cerr << "Ram readed: " << nexus.patches.ram_readed << endl;
nexus.patches.ram_flushed = 0;
nexus.patches.ram_readed = 0;
cerr << "Time for frame: " << watch.Elapsed() << endl;
}
SDL_GL_SwapBuffers();
}

View File

@ -15,6 +15,9 @@ bool PatchServer::Create(const std::string &filename,
frame = 0;
ram_size = rsize;
ram_used = 0;
ram_readed = 0;
ram_flushed = 0;
lru.clear();
return File::Create(filename);
}
@ -27,6 +30,9 @@ bool PatchServer::Load(const std::string &filename, Signature sig,
ram_size = rsize;
frame = 0;
ram_used = 0;
ram_readed = 0;
ram_flushed = 0;
lru.clear();
return File::Load(filename, readonly);
}
@ -123,6 +129,7 @@ Patch &PatchServer::GetPatch(unsigned int idx,
entry.lru_pos = lru.size();
lru.push_back(PTime(idx, frame++));
ram_used += entry.ram_size;
ram_readed += entry.ram_size;
}
//avoid frame overflow!
@ -141,7 +148,7 @@ Patch &PatchServer::GetPatch(unsigned int idx,
void PatchServer::Flush() {
if(ram_used < ram_size * 1.5) return;
if(ram_used < ram_size * 1.1) return;
make_heap(lru.begin(), lru.end());
for(unsigned int i = 0; i < lru.size(); i++)
@ -209,6 +216,7 @@ void PatchServer::Flush(unsigned int patch) {
entry.patch = NULL;
entry.lru_pos = 0xffffffff;
ram_used -= entry.ram_size;
ram_flushed += entry.ram_size;
}
void PatchServer::SetRamBufferSize(unsigned int r_buffer) {

View File

@ -31,9 +31,14 @@ class PatchServer: public File {
Signature signature;
unsigned int chunk_size;
unsigned int ram_size;
unsigned int ram_used;
unsigned int frame;
//statistics:
unsigned int ram_readed;
unsigned int ram_flushed;
bool Create(const std::string &filename, Signature signature,