/** * @dataProvider getFixtures * * @param string $path * @param int $iterations */ public function testPerformance($path, $iterations) { $runs = array_pad([], $iterations, -1); foreach ($runs as &$iteration) { $start = microtime(true); $parser = new Parser(); $tokeniser = new StreamTokeniser(new CsvConfiguration(), fopen($path, 'r')); foreach ($parser->parse($tokeniser->getTokens()) as $row) { echo ''; } $iteration = microtime(true) - $start; } $average = array_sum($runs) / count($runs); printf("\nPath: %s - iterations: %d - average: %.2f ms\n", $path, count($runs), $average * 1000); }
/** * @param resource $stream * * @return Iterator */ public function parse($stream) { $tokeniser = new StreamTokeniser($this->csvFormat, $stream); $parser = new Parser(); return $this->parseIterator($parser->parse($tokeniser->getTokens())); }
/** * @return Iterator Iterator of csv line arrays */ public function read() { $tokens = new StreamTokeniser($this->config, $this->stream); $parser = new Parser(); return $parser->parse($tokens->getTokens()); }