-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathStringHelperBench.php
More file actions
103 lines (83 loc) · 2.33 KB
/
Copy pathStringHelperBench.php
File metadata and controls
103 lines (83 loc) · 2.33 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
declare(strict_types=1);
namespace Yiisoft\Strings\Tests\Benchmark;
use PhpBench\Benchmark\Metadata\Annotations\Iterations;
use PhpBench\Benchmark\Metadata\Annotations\Revs;
use PhpBench\Benchmark\Metadata\Annotations\Warmup;
use Yiisoft\Strings\StringHelper;
/**
* @Iterations(10)
* @Revs(1000)
* @Warmup(2)
*/
final class StringHelperBench
{
public function benchByteLength(): void
{
StringHelper::byteLength('Hello, world!');
}
public function benchByteSubstring(): void
{
StringHelper::byteSubstring('Hello, world!', 7, 5);
}
public function benchBaseName(): void
{
StringHelper::baseName('/path/to/file.php', '.php');
}
public function benchDirectoryName(): void
{
StringHelper::directoryName('/path/to/file.php');
}
public function benchSubstring(): void
{
StringHelper::substring('Hello, world!', 7, 5);
}
public function benchReplaceSubstring(): void
{
StringHelper::replaceSubstring('Hello, world!', 'planet', 7, 5);
}
public function benchStartsWith(): void
{
StringHelper::startsWith('Hello, world!', 'Hello');
}
public function benchStartsWithIgnoringCase(): void
{
StringHelper::startsWithIgnoringCase('Hello, world!', 'hello');
}
public function benchEndsWith(): void
{
StringHelper::endsWith('Hello, world!', 'world!');
}
public function benchEndsWithIgnoringCase(): void
{
StringHelper::endsWithIgnoringCase('Hello, world!', 'World!');
}
public function benchTruncateBegin(): void
{
StringHelper::truncateBegin('Hello, world!', 10);
}
public function benchTruncateMiddle(): void
{
StringHelper::truncateMiddle('Hello, world!', 10);
}
public function benchTruncateEnd(): void
{
StringHelper::truncateEnd('Hello, world!', 10);
}
public function benchSplit(): void
{
StringHelper::split('Hello, world!', ' ');
}
public function benchTrim(): void
{
StringHelper::trim(' Hello, world! ');
}
public function benchFindBetween(): void
{
StringHelper::findBetween('<a>b</a>', '<a>', '</a>');
}
public function benchMatchAnyRegex(): void
{
StringHelper::matchAnyRegex('string', ['/[a-z]+/', '/[0-9]+/']);
}
}