Patch level : 10.0

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Performance test suite


git-svn-id: svn://10.65.10.50/trunk@16647 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-05-22 13:40:40 +00:00
parent e0fbf5b54c
commit 305b1e777b
5 changed files with 224 additions and 47 deletions

View File

@ -261,6 +261,16 @@ bool TMenuitem::perform_submenu() const
return ok;
}
bool TMenuitem::run_modal() const
{
bool yes = true;
if (submenu().menu().mask_mode() == 3)
{
yes = _action.match("ba[128] -*", true);
}
return yes;
}
bool TMenuitem::perform_program() const
{
bool ok = true;
@ -303,15 +313,15 @@ bool TMenuitem::perform_program() const
}
else
{
if (submenu().menu().mask_mode() == 3 && !_action.match("ba[1-2] -*", true))
a.run(true, 3, false); //e' un programma asincrono
else
if (run_modal())
{
prefix().set(NULL); // Chiude prefix
a.run(false, 3); // e' un programma sincrono
printer_destroy(); // Forza rilettura parametri della stampante
prefix().set("DEF"); // Riapre prefix
}
else
a.run(true, 3, false); //e' un programma asincrono
}
}

View File

@ -51,9 +51,10 @@ public:
bool enabled() const;
bool disabled() const { return !enabled(); }
bool is_submenu() const { return _type == '[' && _action.not_empty(); }
bool is_program() const { return _type != '[' && _action.not_empty(); }
bool is_submenu() const { return _type == '[' && _action.full(); }
bool is_program() const { return _type != '[' && _action.full(); }
bool perform() const;
bool run_modal() const;
TSubmenu& submenu() const { return *_submenu; }
TMenu& menu() const;

View File

@ -1219,11 +1219,12 @@ TExplorer_mask::TExplorer_mask(TMenu& menu) : _tree(menu)
add_button_tool(DLG_SHRINK, TR("Menu Principale"), TOOL_FIRSTREC);
add_button_tool(DLG_FINDREC, TR("Ricerca"), TOOL_LENTE);
add_button_tool(TOOL_CONFIG, TR("Opzioni"), TOOL_CONFIG);
add_button_tool(DLG_SETPRINT, TR(""), TOOL_SETPRINT);
add_button_tool(TOOL_PREF, TR("Preferiti"), TOOL_PREF);
add_button_tool(TOOL_ADDPREF,TR("Aggiungi ai Preferiti"), TOOL_ADDPREF);
add_button_tool(TOOL_ADDPREF, TR("Aggiungi ai Preferiti"), TOOL_ADDPREF);
add_button_tool(DLG_INFO, TR("Info"), TOOL_INFO);
add_button_tool(DLG_HELP, TR("Help"), TOOL_HELP);
add_button_tool(DLG_QUIT, TR("Fine"), TOOL_QUIT);
add_button_tool(DLG_QUIT, TR(""), TOOL_QUIT);
WINDOW panel = page_win(0);

View File

@ -326,7 +326,7 @@ bool TOutlook_mask::on_field_event(TOperable_field& o, TField_event e, long joll
else
{
// ba1 e ba2 sono programmi di manutenzione da eseguire in modo esclusivo
const bool manu = mi.action().match("ba[1-2] -*", true);
const bool manu = mi.run_modal();
if (manu)
{
TBook_field& bf = (TBook_field&)field(DLG_MAIN);

View File

@ -1,7 +1,35 @@
#include <applicat.h>
#include <mask.h>
#include <progind.h>
#include <recarray.h>
#include <relation.h>
#include <tabutil.h>
#include <reputils.h>
#include <urldefid.h>
class TProfiler_mask : public TMask
{
public:
TProfiler_mask();
};
TProfiler_mask::TProfiler_mask() : TMask(TR("Test"), 1, 60, 12)
{
create_bar(-2);
TToken_string codes, items;
codes.add(0); items.add(TR("Tutti i test"));
codes.add(1); items.add(TR("Lettura sequenziale tabella"));
codes.add(2); items.add(TR("Lettura cursore su chiave primaria"));
codes.add(3); items.add(TR("Lettura cursore con ordinamento fuori chiave"));
codes.add(4); items.add(TR("Lettura causale con cache"));
codes.add(5); items.add(TR("Creazione e cancellazione records"));
add_radio(101, 0, TR("@bSelezione test"), 1, 1, 58, codes, items);
add_number(102, 0, PR("Numero di iterazioni"), 1, 0, 3, "U");
add_button(DLG_OK, MAX_PAGES, PR("Elabora"), -12, -11, 10, 2, "", BMP_ELABORA);
add_button(DLG_QUIT, MAX_PAGES, "", -22, -11, 10, 2);
}
///////////////////////////////////////////////////////////
// Testfile
@ -10,14 +38,15 @@
class TTest_application : public TSkeleton_application
{
protected:
void test1();
void test2();
void test3();
void test4();
bool test1(TLog_report& log);
bool test2(TLog_report& log);
bool test3(TLog_report& log);
bool test4(TLog_report& log);
bool test5(TLog_report& log);
clock_t start_timer() const;
public:
bool test(int n, TLog_report& log);
virtual void main_loop();
};
@ -29,8 +58,9 @@ clock_t TTest_application::start_timer() const
return t;
}
void TTest_application::test1()
bool TTest_application::test1(TLog_report& log)
{
bool ok = true;
TLocalisamfile tab(LF_COMUNI);
clock_t start;
@ -46,20 +76,26 @@ void TTest_application::test1()
r++;
msg.format("%ld records %ld msec", r, clock() - start);
p.addstatus(1);
p.set_text(msg);
if (p.iscancelled())
if (!p.addstatus(1))
{
log.log(1, TR("Interrotto dall'utente"));
ok = false;
break;
}
}
}
const clock_t t = clock() - start;
msg.format("Lettura file comuni\n"
"%ld records in %ld msec\n%lg records per sec", r, t, 1000.0*r/t);
message_box(msg);
msg.format("Lettura file comuni - "
"%ld records in %ld msec - %lg records per sec", r, t, 1000.0*r/t);
log.log(0, msg);
return ok;
}
void TTest_application::test2()
bool TTest_application::test2(TLog_report& log)
{
bool ok = true;
TRelation rel(LF_COMUNI);
TCursor tab(&rel);
@ -80,20 +116,25 @@ void TTest_application::test2()
r++;
msg.format("Lettura cursore comuni\n%ld records %ld msec", r, clock() - start);
p.addstatus(1);
p.set_text(msg);
if (p.iscancelled())
if (!p.addstatus(1))
{
log.log(1, TR("Interrotto dall'utente"));
ok = false;
break;
}
}
}
const clock_t t = clock() - start;
msg.format("%ld records in %ld msec\n%lg records per sec\n",
msg.format("Lettura cursore comuni: %ld records in %ld msec - %lg records per sec\n",
r, t, 1000.0*r/t);
message_box(msg);
log.log(0, msg);
return ok;
}
void TTest_application::test3()
bool TTest_application::test3(TLog_report& log)
{
bool ok = true;
TRelation rel(LF_COMUNI);
TSorted_cursor tab(&rel, "CAPCOM|DENCOM");
@ -116,21 +157,26 @@ void TTest_application::test3()
r++;
msg.format("Lettura cursore C.A.P.\n%ld records %ld msec", r, clock() - start);
p.addstatus(1);
p.set_text(msg);
if (p.iscancelled())
if (!p.addstatus(1))
{
log.log(1, TR("Interrotto dall'utente"));
ok = false;
break;
}
}
}
const clock_t t = clock() - start;
msg.format("%ld records in %ld msec\n%lg records per sec\n"
msg.format("Lettura cursore ordinato %ld records in %ld msec - %lg records per sec - "
"%ld msec for initialization",
r, t, 1000.0*r/t, istop);
message_box(msg);
log.log(0, msg);
return ok;
}
void TTest_application::test4()
bool TTest_application::test4(TLog_report& log)
{
bool ok = true;
long r = 0;
srand(r);
TString8 cod;
@ -149,29 +195,148 @@ void TTest_application::test4()
cache().get(LF_COMUNI, cod);
r++;
}
p.addstatus(1);
if (p.iscancelled())
if (!p.addstatus(1))
{
log.log(1, TR("Interrotto dall'utente"));
ok = false;
break;
}
}
}
const clock_t t = clock() - start;
TString msg;
msg.format("%ld records in %ld msec\n%lg records per sec", r, t, 1000.0*r/t);
message_box(msg);
msg.format("Lettura casuale di %ld records in %ld msec - %lg records per sec",
r, t, 1000.0*r/t);
log.log(0, msg);
return ok;
}
bool TTest_application::test5(TLog_report& log)
{
bool ok = true;
TString msg;
TRecnotype n = 100;
if (n > 0)
{
TTable tab("CZZ");
msg.format("Creazione di %ld records", n);
TProgind p(n, msg, true, true);
clock_t start = start_timer();
for (int i = 1; i <= n; i++)
{
if ((i % 10) == 0 && !p.setstatus(i))
{
log.log(1, TR("Interrotto dall'utente"));
ok = false;
break;
}
tab.put("CODTAB", i);
tab.write();
}
const clock_t t = clock() - start;
msg.format("Scritti %ld records in %ld msec - %lg records per sec", n, t, 1000.0*n/t);
log.log(0, msg);
}
if (n > 0)
{
TRelation rel("CZZ");
TCursor cur(&rel);
n = cur.items();
cur.freeze();
msg.format("Cancellazione %ld records", n);
TProgind p(n, msg, true, true);
clock_t start = start_timer();
for (cur = 0; cur.pos() < n; ++cur)
{
const int i = cur.pos()+1;
if ((i % 10) == 0 && !p.setstatus(i))
{
log.log(1, TR("Interrotto dall'utente"));
ok = false;
break;
}
cur.file().remove();
}
const clock_t t = clock() - start;
msg.format("Cancellati %ld records in %ld msec - %lg records per sec", n, t, 1000.0*n/t);
log.log(0, msg);
}
return ok;
}
bool TTest_application::test(int n, TLog_report& log)
{
bool ok = false;
switch (n)
{
case 1: ok = test1(log); break;
case 2: ok = test2(log); break;
case 3: ok = test3(log); break;
case 4: ok = test4(log); break;
case 5: ok = test5(log); break;
default: ok = false; break;
}
return ok;
}
void TTest_application::main_loop()
{
test1();
test2();
test3();
test4();
int te = -1;
int ti = 3;
for (int a = argc()-1; a > 1; a--)
{
const TFixed_string t(argv(a));
if (t.starts_with("test="))
te = atoi(t.mid(5)); else
if (t.starts_with("times="))
ti = atoi(t.mid(6));
}
const bool interactive = te < 0;
while (true)
{
if (interactive)
{
TProfiler_mask m;
m.set(101, te);
m.set(102, ti);
if (m.run() == K_QUIT)
break;
te = m.get_int(101);
ti = m.get_int(102);
if (ti <= 0)
ti = 1;
}
TLog_report log("Report");
bool ok = true;
for (int t = 1; ok && t <= 5; t++)
{
if (te <= 0 || te == t)
{
log.log(0, "");
for (int i = 0; ok && i < ti; i++)
ok = test(t, log);
}
}
if (interactive)
log.preview();
else
break;
}
}
///////////////////////////////////////////////////////////
int ba1200(int argc, char** argv)
{
TTest_application a;