Added statistics.
This commit is contained in:
parent
c65e4840b1
commit
54a1d90730
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$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
|
Revision 1.11 2004/10/04 16:49:54 ponchio
|
||||||
Daily backup. Preparing for compression.
|
Daily backup. Preparing for compression.
|
||||||
|
|
||||||
|
@ -91,6 +94,7 @@ using namespace std;
|
||||||
|
|
||||||
|
|
||||||
#include <wrap/gui/trackball.h>
|
#include <wrap/gui/trackball.h>
|
||||||
|
#include "stopwatch.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace vcg;
|
using namespace vcg;
|
||||||
|
@ -152,8 +156,7 @@ int main(int argc, char *argv[]) {
|
||||||
// int option;
|
// int option;
|
||||||
|
|
||||||
if(argc != 2) {
|
if(argc != 2) {
|
||||||
cerr << "Usage: " << argv[0] << " <nexus file>\n";
|
cerr << "Usage: " << argv[0] << " <nexus file>\n"; return -1;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NexusMt nexus;
|
NexusMt nexus;
|
||||||
|
@ -175,19 +178,25 @@ int main(int argc, char *argv[]) {
|
||||||
" s: screen error extraction\n"
|
" s: screen error extraction\n"
|
||||||
" g: geometry error extraction\n"
|
" g: geometry error extraction\n"
|
||||||
" p: draw points\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"
|
" d: debug mode (show patches colored)\n"
|
||||||
" m: smooth mode\n"
|
" m: smooth mode\n"
|
||||||
" c: show colors\n"
|
" c: show colors\n"
|
||||||
" n: show normals\n"
|
" n: show normals\n"
|
||||||
" r: rotate model\n"
|
" u: rotate model\n"
|
||||||
" -: decrease error\n"
|
" -: decrease error\n"
|
||||||
" +: increase error (= too)\n";
|
" +: increase error (= too)\n";
|
||||||
|
|
||||||
|
StopWatch watch;
|
||||||
|
|
||||||
bool rotate = false;
|
bool rotate = false;
|
||||||
bool show_borders = true;
|
bool show_borders = true;
|
||||||
bool show_colors = true;
|
bool show_colors = true;
|
||||||
bool show_normals = true;
|
bool show_normals = true;
|
||||||
|
bool show_statistics = true;
|
||||||
NexusMt::Mode mode = NexusMt::SMOOTH;
|
NexusMt::Mode mode = NexusMt::SMOOTH;
|
||||||
NexusMt::PolicyKind policy = NexusMt::FRUSTUM;
|
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_b: show_borders = !show_borders; break;
|
||||||
case SDLK_c: show_colors = !show_colors; break;
|
case SDLK_c: show_colors = !show_colors; break;
|
||||||
case SDLK_n: show_normals = !show_normals; 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_s: policy = NexusMt::FRUSTUM; break;
|
||||||
case SDLK_p: mode = NexusMt::POINTS; break;
|
case SDLK_p: mode = NexusMt::POINTS; break;
|
||||||
|
@ -227,12 +238,10 @@ int main(int argc, char *argv[]) {
|
||||||
case SDLK_r:
|
case SDLK_r:
|
||||||
case SDLK_SPACE: rotate = !rotate; break;
|
case SDLK_SPACE: rotate = !rotate; break;
|
||||||
|
|
||||||
case SDLK_MINUS: error *= 0.9f;
|
case SDLK_MINUS: error *= 0.9f; break;
|
||||||
cerr << "error: " << error << endl; break;
|
|
||||||
|
|
||||||
case SDLK_EQUALS:
|
case SDLK_EQUALS:
|
||||||
case SDLK_PLUS: error *= 1.1f;
|
case SDLK_PLUS: error *= 1.1f; break;
|
||||||
cerr << "error: " << error << endl; break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
|
@ -315,7 +324,21 @@ int main(int argc, char *argv[]) {
|
||||||
nexus.SetComponent(NexusMt::COLOR, show_colors);
|
nexus.SetComponent(NexusMt::COLOR, show_colors);
|
||||||
nexus.SetComponent(NexusMt::NORMAL, show_normals);
|
nexus.SetComponent(NexusMt::NORMAL, show_normals);
|
||||||
|
|
||||||
|
watch.Restart();
|
||||||
|
|
||||||
nexus.Render();
|
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();
|
SDL_GL_SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,9 @@ bool PatchServer::Create(const std::string &filename,
|
||||||
frame = 0;
|
frame = 0;
|
||||||
ram_size = rsize;
|
ram_size = rsize;
|
||||||
ram_used = 0;
|
ram_used = 0;
|
||||||
|
|
||||||
|
ram_readed = 0;
|
||||||
|
ram_flushed = 0;
|
||||||
lru.clear();
|
lru.clear();
|
||||||
return File::Create(filename);
|
return File::Create(filename);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +30,9 @@ bool PatchServer::Load(const std::string &filename, Signature sig,
|
||||||
ram_size = rsize;
|
ram_size = rsize;
|
||||||
frame = 0;
|
frame = 0;
|
||||||
ram_used = 0;
|
ram_used = 0;
|
||||||
|
|
||||||
|
ram_readed = 0;
|
||||||
|
ram_flushed = 0;
|
||||||
lru.clear();
|
lru.clear();
|
||||||
return File::Load(filename, readonly);
|
return File::Load(filename, readonly);
|
||||||
}
|
}
|
||||||
|
@ -123,6 +129,7 @@ Patch &PatchServer::GetPatch(unsigned int idx,
|
||||||
entry.lru_pos = lru.size();
|
entry.lru_pos = lru.size();
|
||||||
lru.push_back(PTime(idx, frame++));
|
lru.push_back(PTime(idx, frame++));
|
||||||
ram_used += entry.ram_size;
|
ram_used += entry.ram_size;
|
||||||
|
ram_readed += entry.ram_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
//avoid frame overflow!
|
//avoid frame overflow!
|
||||||
|
@ -141,7 +148,7 @@ Patch &PatchServer::GetPatch(unsigned int idx,
|
||||||
|
|
||||||
void PatchServer::Flush() {
|
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());
|
make_heap(lru.begin(), lru.end());
|
||||||
for(unsigned int i = 0; i < lru.size(); i++)
|
for(unsigned int i = 0; i < lru.size(); i++)
|
||||||
|
@ -209,6 +216,7 @@ void PatchServer::Flush(unsigned int patch) {
|
||||||
entry.patch = NULL;
|
entry.patch = NULL;
|
||||||
entry.lru_pos = 0xffffffff;
|
entry.lru_pos = 0xffffffff;
|
||||||
ram_used -= entry.ram_size;
|
ram_used -= entry.ram_size;
|
||||||
|
ram_flushed += entry.ram_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PatchServer::SetRamBufferSize(unsigned int r_buffer) {
|
void PatchServer::SetRamBufferSize(unsigned int r_buffer) {
|
||||||
|
|
|
@ -31,9 +31,14 @@ class PatchServer: public File {
|
||||||
|
|
||||||
Signature signature;
|
Signature signature;
|
||||||
unsigned int chunk_size;
|
unsigned int chunk_size;
|
||||||
|
|
||||||
unsigned int ram_size;
|
unsigned int ram_size;
|
||||||
unsigned int ram_used;
|
unsigned int ram_used;
|
||||||
unsigned int frame;
|
unsigned int frame;
|
||||||
|
|
||||||
|
//statistics:
|
||||||
|
unsigned int ram_readed;
|
||||||
|
unsigned int ram_flushed;
|
||||||
|
|
||||||
|
|
||||||
bool Create(const std::string &filename, Signature signature,
|
bool Create(const std::string &filename, Signature signature,
|
||||||
|
|
Loading…
Reference in New Issue