Migliorato benchmark
git-svn-id: svn://10.65.10.50/trunk@3953 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
972e56a4bd
commit
5678846ebd
71
ba/ba883.cpp
71
ba/ba883.cpp
@ -1,6 +1,5 @@
|
||||
#include <time.h>
|
||||
|
||||
#include <progind.h>
|
||||
#include <relapp.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
@ -161,7 +160,6 @@ bool TTest_application::menu(MENU_TAG)
|
||||
|
||||
class TBenchmark_application : public TApplication
|
||||
{
|
||||
TIndwin* _iw;
|
||||
clock_t _timer_start;
|
||||
|
||||
protected:
|
||||
@ -171,57 +169,54 @@ protected:
|
||||
|
||||
void initializing();
|
||||
void start_test(const char* msg);
|
||||
void update_bar(long rec);
|
||||
void stop_test();
|
||||
|
||||
void test_relation_scan();
|
||||
void test_cursor_scan();
|
||||
|
||||
public:
|
||||
TBenchmark_application() : _iw(NULL) { }
|
||||
TBenchmark_application() { }
|
||||
virtual ~TBenchmark_application() { }
|
||||
};
|
||||
|
||||
bool TBenchmark_application::create()
|
||||
{
|
||||
dispatch_e_menu(MENU_ITEM(1));
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TBenchmark_application::destroy()
|
||||
{
|
||||
if (_iw)
|
||||
{
|
||||
delete _iw;
|
||||
_iw = NULL;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
bool TBenchmark_application::menu(MENU_TAG)
|
||||
bool TBenchmark_application::menu(MENU_TAG mt)
|
||||
{
|
||||
TString test = argv(1); test.upper();
|
||||
const bool test_all = test.find('*') >= 0;
|
||||
|
||||
if (test_all || test.find('R') >= 0)
|
||||
test_relation_scan();
|
||||
if (mt == BAR_ITEM(1))
|
||||
{
|
||||
TString test = argv(1); test.upper();
|
||||
const bool test_all = test.find('*') >= 0;
|
||||
|
||||
if (test_all || test.find('C') >= 0)
|
||||
test_cursor_scan();
|
||||
|
||||
if (test_all || test.find('R') >= 0)
|
||||
test_relation_scan();
|
||||
|
||||
if (test_all || test.find('C') >= 0)
|
||||
test_cursor_scan();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TBenchmark_application::initializing()
|
||||
{
|
||||
CHECK(_iw == NULL, "Benchmark already in progress");
|
||||
_iw = new TIndwin(48, "Initializing ...", TRUE, FALSE, 48);
|
||||
xvt_statbar_set("Initializing...");
|
||||
do_events();
|
||||
}
|
||||
|
||||
void TBenchmark_application::start_test(const char* text)
|
||||
{
|
||||
CHECK(_iw != NULL, "Benchmark not started yet");
|
||||
_iw->set_text(text);
|
||||
xvt_statbar_set(text);
|
||||
do_events();
|
||||
|
||||
clock_t t;
|
||||
@ -235,18 +230,26 @@ void TBenchmark_application::start_test(const char* text)
|
||||
|
||||
void TBenchmark_application::stop_test()
|
||||
{
|
||||
CHECK(_iw != NULL, "Benchmark not started yet");
|
||||
const clock_t t = clock() - _timer_start;
|
||||
const double s = t / CLOCKS_PER_SEC;
|
||||
TString80 msg;
|
||||
msg.format("Time to complete: %.1lf s", s);
|
||||
_iw->set_text(msg);
|
||||
|
||||
while (!_iw->iscancelled())
|
||||
do_events();
|
||||
|
||||
delete _iw;
|
||||
_iw = NULL;
|
||||
message_box(msg);
|
||||
}
|
||||
|
||||
void TBenchmark_application::update_bar(long rec)
|
||||
{
|
||||
if ((rec & 0x7F) == 0)
|
||||
{
|
||||
const double sec = double(clock() - _timer_start) / CLOCKS_PER_SEC;
|
||||
if (sec > 0.0)
|
||||
{
|
||||
TString80 msg;
|
||||
msg.format("%ld records at %ld rec/sec", rec, long(rec / sec));
|
||||
xvt_statbar_set(msg);
|
||||
do_events();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TBenchmark_application::test_relation_scan()
|
||||
@ -259,8 +262,11 @@ void TBenchmark_application::test_relation_scan()
|
||||
|
||||
start_test("Scansione relazione COMUNI+%UID");
|
||||
|
||||
while (!comuni.eof())
|
||||
for (TRecnotype rec = 0; !comuni.eof(); rec++)
|
||||
{
|
||||
comuni.next();
|
||||
update_bar(rec);
|
||||
}
|
||||
|
||||
stop_test();
|
||||
}
|
||||
@ -278,7 +284,10 @@ void TBenchmark_application::test_cursor_scan()
|
||||
start_test("Scansione cursore COMUNI+%UID");
|
||||
|
||||
while (cur.ok())
|
||||
{
|
||||
++cur;
|
||||
update_bar(cur.pos());
|
||||
}
|
||||
|
||||
stop_test();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user