1 | <?php |
||
2 | |||
3 | namespace Doctrine\Tests\DBAL\Performance; |
||
4 | |||
5 | use Doctrine\DBAL\Types\Type; |
||
6 | use Doctrine\Tests\DbalPerformanceTestCase; |
||
7 | |||
8 | /** |
||
9 | * Class TypeConversionPerformanceTest |
||
10 | * @package Doctrine\Tests\DBAL\Performance |
||
11 | * @author Bill Schaller |
||
12 | * @group performance |
||
13 | */ |
||
14 | class TypeConversionPerformanceTest extends DbalPerformanceTestCase |
||
15 | { |
||
16 | /** |
||
17 | * @throws \Doctrine\DBAL\DBALException |
||
18 | * @dataProvider itemCountProvider |
||
19 | */ |
||
20 | public function testDateTimeTypeConversionPerformance($count) |
||
21 | { |
||
22 | $value = new \DateTime; |
||
23 | $type = Type::getType("datetime"); |
||
24 | $platform = $this->_conn->getDatabasePlatform(); |
||
25 | $this->startTiming(); |
||
26 | for ($i = 0; $i < $count; $i++) { |
||
27 | $type->convertToDatabaseValue($value, $platform); |
||
28 | } |
||
29 | $this->stopTiming(); |
||
30 | } |
||
31 | |||
32 | View Code Duplication | public function itemCountProvider() |
|
0 ignored issues
–
show
|
|||
33 | { |
||
34 | return [ |
||
35 | '100 items' => [100], |
||
36 | '1000 items' => [1000], |
||
37 | '10000 items' => [10000], |
||
38 | '100000 items' => [100000], |
||
39 | ]; |
||
40 | } |
||
41 | } |
||
42 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.