Corretto programma di benchmark
git-svn-id: svn://10.65.10.50/trunk@3802 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
cc196d4c93
commit
dd01903edd
62
ba/ba883.cpp
62
ba/ba883.cpp
@ -88,7 +88,7 @@ bool TTest_application::menu(MENU_TAG)
|
|||||||
class TBenchmark_application : public TApplication
|
class TBenchmark_application : public TApplication
|
||||||
{
|
{
|
||||||
TIndwin* _iw;
|
TIndwin* _iw;
|
||||||
clock_t _timer;
|
clock_t _timer_start;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool create();
|
virtual bool create();
|
||||||
@ -100,6 +100,7 @@ protected:
|
|||||||
void stop_test();
|
void stop_test();
|
||||||
|
|
||||||
void test_relation_scan();
|
void test_relation_scan();
|
||||||
|
void test_cursor_scan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TBenchmark_application() : _iw(NULL) { }
|
TBenchmark_application() : _iw(NULL) { }
|
||||||
@ -126,43 +127,48 @@ bool TBenchmark_application::destroy()
|
|||||||
bool TBenchmark_application::menu(MENU_TAG)
|
bool TBenchmark_application::menu(MENU_TAG)
|
||||||
{
|
{
|
||||||
TString test = argv(1); test.upper();
|
TString test = argv(1); test.upper();
|
||||||
const bool test_all = test.find('A') >= 0;
|
const bool test_all = test.find('*') >= 0;
|
||||||
|
|
||||||
if (test_all || test.find('R') >= 0)
|
if (test_all || test.find('R') >= 0)
|
||||||
test_relation_scan();
|
test_relation_scan();
|
||||||
|
|
||||||
|
if (test_all || test.find('C') >= 0)
|
||||||
|
test_cursor_scan();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TBenchmark_application::initializing()
|
void TBenchmark_application::initializing()
|
||||||
{
|
{
|
||||||
CHECK(_iw == NULL, "Benchmark already in progress");
|
CHECK(_iw == NULL, "Benchmark already in progress");
|
||||||
_iw = new TIndwin(48, "Initializing ...", FALSE, TRUE, 48);
|
_iw = new TIndwin(48, "Initializing ...", TRUE, FALSE, 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TBenchmark_application::start_test(const char* text)
|
void TBenchmark_application::start_test(const char* text)
|
||||||
{
|
{
|
||||||
CHECK(_iw != NULL, "Benchmark not started yet");
|
CHECK(_iw != NULL, "Benchmark not started yet");
|
||||||
_iw->set_text(text);
|
_iw->set_text(text);
|
||||||
|
do_events();
|
||||||
|
|
||||||
clock_t _timer = clock(), t;
|
clock_t t;
|
||||||
|
_timer_start = clock();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
t = clock();
|
t = clock();
|
||||||
} while (t == _timer);
|
} while (t == _timer_start);
|
||||||
_timer = t;
|
_timer_start = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TBenchmark_application::stop_test()
|
void TBenchmark_application::stop_test()
|
||||||
{
|
{
|
||||||
CHECK(_iw != NULL, "Benchmark not started yet");
|
CHECK(_iw != NULL, "Benchmark not started yet");
|
||||||
const clock_t t = clock() - _timer;
|
const clock_t t = clock() - _timer_start;
|
||||||
const double s = t / CLOCKS_PER_SEC;
|
const double s = t / CLOCKS_PER_SEC;
|
||||||
TString80 msg;
|
TString80 msg;
|
||||||
msg.format("Time to complete: %.1lf s", s);
|
msg.format("Time to complete: %.1lf s", s);
|
||||||
_iw->set_text(msg);
|
_iw->set_text(msg);
|
||||||
|
|
||||||
while (!_iw->is_cancelled())
|
while (!_iw->iscancelled())
|
||||||
do_events();
|
do_events();
|
||||||
|
|
||||||
delete _iw;
|
delete _iw;
|
||||||
@ -177,7 +183,7 @@ void TBenchmark_application::test_relation_scan()
|
|||||||
comuni.add("%UID", "CODTAB=UFFIIDD1");
|
comuni.add("%UID", "CODTAB=UFFIIDD1");
|
||||||
comuni.first();
|
comuni.first();
|
||||||
|
|
||||||
start_test("Scansione COMUNI+%UID");
|
start_test("Scansione relazione COMUNI+%UID");
|
||||||
|
|
||||||
while (!comuni.eof())
|
while (!comuni.eof())
|
||||||
comuni.next();
|
comuni.next();
|
||||||
@ -185,35 +191,41 @@ void TBenchmark_application::test_relation_scan()
|
|||||||
stop_test();
|
stop_test();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TBenchmark_application::test_cursor_scan()
|
||||||
|
{
|
||||||
|
initializing();
|
||||||
|
|
||||||
|
TRelation comuni(LF_COMUNI);
|
||||||
|
comuni.add("%UID", "CODTAB=UFFIIDD1");
|
||||||
|
|
||||||
|
TCursor cur(&comuni);
|
||||||
|
cur = 0L;
|
||||||
|
|
||||||
|
start_test("Scansione cursore COMUNI+%UID");
|
||||||
|
|
||||||
|
while (cur.ok())
|
||||||
|
++cur;
|
||||||
|
|
||||||
|
stop_test();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
TApplication::check_parameters(argc, argv);
|
TApplication::check_parameters(argc, argv);
|
||||||
|
|
||||||
if (argc > 1 && *argv[0] == '-')
|
if (argc > 1 && *argv[1] == '-')
|
||||||
{
|
{
|
||||||
TBenchmark_application bma;
|
TBenchmark_application bma;
|
||||||
bma.run();
|
bma.run(argc, argv, "Benchmark");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
{
|
{
|
||||||
TFilename n;
|
TFilename n = argv[1];
|
||||||
if (argc == 1)
|
|
||||||
{
|
|
||||||
TMask m("Inserire il nome della maschera", 1, 42, 4);
|
|
||||||
m.add_string(101, 0, "", 1, 1, 40);
|
|
||||||
m.field(101).check_type(CHECK_REQUIRED);
|
|
||||||
m.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
|
|
||||||
m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
|
|
||||||
if (m.run() == K_ENTER)
|
|
||||||
n = m.get(101);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
n = argv[1];
|
|
||||||
|
|
||||||
if (n.not_empty())
|
if (n.not_empty())
|
||||||
{
|
{
|
||||||
TTest_application a(n);
|
TTest_application a(n);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user