-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
32 lines (24 loc) · 943 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
namespace Kallehauge\AhoCorasick;
use Kallehauge\AhoCorasick\Strategy\MatchingStrategyType;
require_once __DIR__ . '/vendor/autoload.php';
$strategy = isset( $argv[1] ) ? (string) $argv[1] : 'aho-corasick';
$test_type = isset( $argv[2] ) ? (string) $argv[2] : 'mobydick';
$iterations = isset( $argv[3] ) ? (int) $argv[3] : 1;
if ( $strategy === 'all' ) {
foreach ( MatchingStrategyType::cases() as $strategy_enum ) {
$reports = [];
$matcher = new Matcher( $strategy_enum->value );
for ( $i = 0; $i < $iterations; $i ++ ) {
$reports[] = $matcher->start( KeywordsLibrary::get(), TextLibrary::get( $test_type ) );
}
Reporter::report( $reports, $strategy_enum->value );
}
} else {
$reports = [];
$matcher = new Matcher( $strategy );
for ( $i = 0; $i < $iterations; $i ++ ) {
$reports[] = $matcher->start( KeywordsLibrary::get(), TextLibrary::get( $test_type ) );
}
Reporter::report( $reports, $strategy );
}