mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.benchmarks
git-svn-id: svn://ultimatepp.org/upp/trunk@6994 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
cbf2f4de95
commit
9e74bd7802
1 changed files with 11 additions and 2 deletions
|
|
@ -75,17 +75,24 @@ void test_find(const char *data, const char *pattern)
|
|||
void DoTest(const String& data, const String& needle)
|
||||
{
|
||||
RLOG("------------");
|
||||
RLOG("Needle: " << needle);
|
||||
RLOG("Needle: " << needle << " (" << needle.GetCount() << ")");
|
||||
{
|
||||
TimeStop tm;
|
||||
RLOG("U++ Brute force: " << data.Find(needle));
|
||||
RLOG(" Time elapsed: " << tm);
|
||||
}
|
||||
{
|
||||
TimeStop tm;
|
||||
void *t = memmem(data, data.GetLength(), needle, needle.GetLength());
|
||||
RLOG("memmem: " << (t ? (char *)t - ~data : -1));
|
||||
RLOG(" Time elapsed: " << tm);
|
||||
}
|
||||
{
|
||||
TimeStop tm;
|
||||
RLOG("Folly: " << ffind(data, data.GetLength(), needle, needle.GetCount()));
|
||||
RLOG(" Time elapsed: " << tm);
|
||||
}
|
||||
#if 0
|
||||
{
|
||||
TimeStop tm;
|
||||
uint8_t* t = boyer_moore ((uint8_t *)~data, data.GetCount(),
|
||||
|
|
@ -99,6 +106,7 @@ void DoTest(const String& data, const String& needle)
|
|||
RLOG("Boyer-Moore: " << bm.FindIn(data));
|
||||
RLOG(" Time elapsed: " << tm);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
|
|
@ -129,6 +137,7 @@ CONSOLE_APP_MAIN
|
|||
DoTest(data, "aab");
|
||||
DoTest(data, "aaab");
|
||||
DoTest(data, "aaaab");
|
||||
DoTest(data, "aaaaaaaaaaaaab");
|
||||
DoTest(data, "aaaaaaaaaaaaaaaaaab");
|
||||
DoTest(data, String('a', 100) + "b");
|
||||
|
||||
|
|
@ -173,6 +182,6 @@ CONSOLE_APP_MAIN
|
|||
n.Set(60, ' ');
|
||||
for(int i = 0; i < 1000000; i++)
|
||||
data << n;
|
||||
data << needle;
|
||||
data << needle << data;
|
||||
DoTest(data, needle);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue