Estesi benchmasrk
git-svn-id: svn://10.65.10.50/trunk@4140 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
cafd3fcd50
commit
6c9802b498
90
ba/ba883.cpp
90
ba/ba883.cpp
@ -174,6 +174,8 @@ protected:
|
||||
|
||||
void test_relation_scan();
|
||||
void test_cursor_scan();
|
||||
void test_file_scan();
|
||||
void test_file_random();
|
||||
|
||||
public:
|
||||
TBenchmark_application() { }
|
||||
@ -199,11 +201,17 @@ 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('F') >= 0)
|
||||
test_file_scan();
|
||||
|
||||
if (test_all || test.find('R') >= 0)
|
||||
test_relation_scan();
|
||||
|
||||
if (test_all || test.find('C') >= 0)
|
||||
test_cursor_scan();
|
||||
|
||||
if (test_all || test.find('T') >= 0)
|
||||
test_file_random();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -231,7 +239,7 @@ void TBenchmark_application::start_test(const char* text)
|
||||
void TBenchmark_application::stop_test()
|
||||
{
|
||||
const clock_t t = clock() - _timer_start;
|
||||
const double s = t / CLOCKS_PER_SEC;
|
||||
const double s = (double)t / CLOCKS_PER_SEC;
|
||||
TString80 msg;
|
||||
msg.format("Time to complete: %.1lf s", s);
|
||||
message_box(msg);
|
||||
@ -252,18 +260,44 @@ void TBenchmark_application::update_bar(long rec)
|
||||
}
|
||||
}
|
||||
|
||||
void TBenchmark_application::test_file_scan()
|
||||
{
|
||||
int found = 0;
|
||||
|
||||
initializing();
|
||||
|
||||
TLocalisamfile comuni(LF_COMUNI);
|
||||
|
||||
start_test("Scansione file COMUNI di Reggio Emilia");
|
||||
|
||||
|
||||
comuni.first();
|
||||
for (TRecnotype rec = 0; !comuni.eof(); rec++)
|
||||
{
|
||||
if (comuni.get("PROVCOM") == "RE")
|
||||
found++;
|
||||
comuni.next();
|
||||
update_bar(rec);
|
||||
}
|
||||
|
||||
stop_test();
|
||||
}
|
||||
|
||||
|
||||
void TBenchmark_application::test_relation_scan()
|
||||
{
|
||||
int found = 0;
|
||||
|
||||
initializing();
|
||||
|
||||
TRelation comuni(LF_COMUNI);
|
||||
comuni.add("%UID", "CODTAB=UFFIIDD1");
|
||||
comuni.first();
|
||||
|
||||
start_test("Scansione relazione COMUNI+%UID");
|
||||
start_test("Scansione relazione COMUNI");
|
||||
|
||||
comuni.first();
|
||||
for (TRecnotype rec = 0; !comuni.eof(); rec++)
|
||||
{
|
||||
if (comuni.curr().get("PROVCOM") == "RE")
|
||||
found++;
|
||||
comuni.next();
|
||||
update_bar(rec);
|
||||
}
|
||||
@ -273,25 +307,57 @@ void TBenchmark_application::test_relation_scan()
|
||||
|
||||
void TBenchmark_application::test_cursor_scan()
|
||||
{
|
||||
int found = 0;
|
||||
initializing();
|
||||
|
||||
TRelation comuni(LF_COMUNI);
|
||||
comuni.add("%UID", "CODTAB=UFFIIDD1");
|
||||
|
||||
TCursor cur(&comuni);
|
||||
|
||||
start_test("Scansione cursore COMUNI");
|
||||
|
||||
TRecnotype tot = cur.items();
|
||||
cur = 0L;
|
||||
|
||||
start_test("Scansione cursore COMUNI+%UID");
|
||||
|
||||
while (cur.ok())
|
||||
for (TRecnotype c = 0; c < tot; c++)
|
||||
{
|
||||
if (comuni.curr().get("PROVCOM") == "RE")
|
||||
found++;
|
||||
++cur;
|
||||
update_bar(cur.pos());
|
||||
update_bar(c);
|
||||
}
|
||||
|
||||
stop_test();
|
||||
}
|
||||
|
||||
void TBenchmark_application::test_file_random()
|
||||
{
|
||||
initializing();
|
||||
|
||||
TLocalisamfile comuni(LF_COMUNI);
|
||||
|
||||
start_test("Lettura randome del file COMUNI");
|
||||
|
||||
TRectype& rec = comuni.curr();
|
||||
char code[8];
|
||||
long found, notfound;
|
||||
|
||||
for (long n = 0; n < 1000; n++)
|
||||
{
|
||||
const char l = 'A' + rand() % 26;
|
||||
const int c = rand() % 100;
|
||||
sprintf(code, "%c%03d", l, c);
|
||||
rec.zero();
|
||||
rec.put("COM", code);
|
||||
if (comuni.read() == NOERR)
|
||||
found++;
|
||||
else
|
||||
notfound++;
|
||||
update_bar(n);
|
||||
}
|
||||
|
||||
stop_test();
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user