Measure the performance of adblock parsing with a unit test
This commit is contained in:
parent
c812efad2b
commit
53b3c6aee3
1 changed files with 28 additions and 0 deletions
|
@ -657,11 +657,39 @@ test_adblock_pattern (void)
|
|||
g_unlink (filename);
|
||||
}
|
||||
|
||||
static void
|
||||
test_adblock_count (void)
|
||||
{
|
||||
gchar* urls[6] = {
|
||||
"https://bugs.webkit.org/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&query_based_on=gtkport&field0-0-0=keywords&type0-0-0=anywordssubstr&value0-0-0=Gtk%20Cairo%20soup&field0-0-1=short_desc&type0-0-1=anywordssubstr&value0-0-1=Gtk%20Cairo%20soup%20autoconf%20automake%20autotool&field0-0-2=component&type0-0-2=equals&value0-0-2=WebKit%20Gtk",
|
||||
"http://www.engadget.com/2009/09/24/google-hits-android-rom-modder-with-a-cease-and-desist-letter/",
|
||||
"http://karibik-invest.com/es/bienes_raices/search.php?sqT=19&sqN=&sqMp=&sqL=0&qR=1&sqMb=&searchMode=1&action=B%FAsqueda",
|
||||
"http://google.com",
|
||||
"http://ya.ru",
|
||||
"http://google.com"
|
||||
};
|
||||
/* FIXME */
|
||||
gchar* filename = "/home/avb/.cache/midori/adblock/bb6cd38a4579b3605946b1228fa65297";
|
||||
gdouble elapsed = 0.0;
|
||||
gchar* str;
|
||||
int i;
|
||||
pattern = adblock_parse_file (filename);
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
str = urls[i];
|
||||
g_test_timer_start ();
|
||||
g_hash_table_find (pattern, (GHRFunc) adblock_is_matched,str);
|
||||
elapsed += g_test_timer_elapsed ();
|
||||
}
|
||||
g_print ("Search took %f seconds\n", elapsed);
|
||||
}
|
||||
|
||||
void
|
||||
extension_test (void)
|
||||
{
|
||||
g_test_add_func ("/extensions/adblock/parse", test_adblock_parse);
|
||||
g_test_add_func ("/extensions/adblock/pattern", test_adblock_pattern);
|
||||
g_test_add_func ("/extensions/adblock/count", test_adblock_count);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue