Aggiunto test hashtable
git-svn-id: svn://10.65.10.50/branches/R_10_00@23156 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
42b2edda46
commit
d00d56e293
@ -406,31 +406,56 @@ bool TTest_application::test7(TLog_report& log)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ostream* _out = NULL;
|
||||||
|
|
||||||
|
static void str_serialize(const TObject& obj)
|
||||||
|
{ *_out << obj << '\n'; }
|
||||||
|
|
||||||
|
static bool str_deserialize(istream& i, TString& str)
|
||||||
|
{
|
||||||
|
char* buff = str.get_buffer(50);
|
||||||
|
bool in_string = false;
|
||||||
|
while (!i.eof())
|
||||||
|
{
|
||||||
|
char c = '\0'; i.get(c);
|
||||||
|
if ((c > '\0' && c < '0') || (c > '9' && c < '@') || (c>'Z' && c < 'a'))
|
||||||
|
{
|
||||||
|
if (in_string)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*buff = c;
|
||||||
|
buff++;
|
||||||
|
in_string = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*buff = '\0';
|
||||||
|
return in_string && str.full();
|
||||||
|
}
|
||||||
|
|
||||||
bool TTest_application::test8(TLog_report& log)
|
bool TTest_application::test8(TLog_report& log)
|
||||||
{
|
{
|
||||||
static TArray parole(1024*1024);
|
static TArray parole(1024*1024);
|
||||||
|
|
||||||
if (parole.empty())
|
TString msg;
|
||||||
|
|
||||||
|
const bool first_time = parole.empty();
|
||||||
|
if (first_time)
|
||||||
{
|
{
|
||||||
const clock_t start = start_progind(n, TR("Lettura big.txt con TArray"));
|
TString80 str;
|
||||||
TString str;
|
msg = TR("Lettura big.txt con TArray");
|
||||||
|
log.log(0, msg);
|
||||||
|
const clock_t start = start_progind(1, msg);
|
||||||
ifstream big("recdesc/big.txt");
|
ifstream big("recdesc/big.txt");
|
||||||
while (!big.eof())
|
while (str_deserialize(big, str))
|
||||||
{
|
{
|
||||||
big >> str;
|
parole.add(str);
|
||||||
if (str.full())
|
_pi->add_status(0L);
|
||||||
{
|
|
||||||
str.trim();
|
|
||||||
if (str.len() <= 16)
|
|
||||||
parole.add(new TString16(str));
|
|
||||||
else
|
|
||||||
parole.add(new TString80(str));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stop_progind();
|
stop_progind();
|
||||||
}
|
}
|
||||||
|
|
||||||
TString msg;
|
|
||||||
const unsigned int n = parole.items();
|
const unsigned int n = parole.items();
|
||||||
bool ok = n > 0;
|
bool ok = n > 0;
|
||||||
|
|
||||||
@ -449,12 +474,22 @@ bool TTest_application::test8(TLog_report& log)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const clock_t t = stop_progind() - start;
|
const clock_t t = stop_progind() - start;
|
||||||
msg.format("Lettura %ld parole in TAssoc_array %6ld msec - %5lg words per sec", n, t, 1000.0*n/t);
|
msg.format("TAssoc_array %ld(%ld) parole %6ld msec - %5lg wps", n, ass.items(), t, 1000.0*n/t);
|
||||||
log.log(0, msg);
|
log.log(0, msg);
|
||||||
|
|
||||||
|
if (first_time)
|
||||||
|
{
|
||||||
|
TFilename fn; fn.tempdir(); fn.add("assoc.txt");
|
||||||
|
_out = new ofstream(fn);
|
||||||
|
ass.for_each(str_serialize);
|
||||||
|
_out->flush();
|
||||||
|
delete _out;
|
||||||
|
_out = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
THash_table ash;
|
THash_table ash(1024*36);
|
||||||
const clock_t start = start_progind(n, TR("Lettura big.txt con THash_table"));
|
const clock_t start = start_progind(n, TR("Lettura big.txt con THash_table"));
|
||||||
FOR_EACH_ARRAY_ITEM(parole, r, o)
|
FOR_EACH_ARRAY_ITEM(parole, r, o)
|
||||||
{
|
{
|
||||||
@ -467,8 +502,19 @@ bool TTest_application::test8(TLog_report& log)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const clock_t t = stop_progind() - start;
|
const clock_t t = stop_progind() - start;
|
||||||
msg.format("Lettura %ld parole in THash_table %6ld msec - %5lg words per sec", n, t, 1000.0*n/t);
|
msg.format("THash_table %ld(%ld) parole %6ld msec - %5lg wps", n, ash.items(), t, 1000.0*n/t);
|
||||||
log.log(0, msg);
|
log.log(0, msg);
|
||||||
|
|
||||||
|
if (first_time)
|
||||||
|
{
|
||||||
|
TFilename fn; fn.tempdir(); fn.add("hash.txt");
|
||||||
|
_out = new ofstream(fn);
|
||||||
|
ash.for_each(str_serialize);
|
||||||
|
_out->flush();
|
||||||
|
delete _out;
|
||||||
|
_out = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user