DiffMatchPatch\PerformanceTest::testDiffMainPerformance PHP Method

testDiffMainPerformance() public method

    public function testDiffMainPerformance()
    {
        $text1 = file_get_contents(__DIR__ . '/fixtures/S_performance1.txt');
        $text2 = file_get_contents(__DIR__ . '/fixtures/S_performance2.txt');
        // Warm up
        $diff = new Diff();
        $diff->setTimeout(0);
        $diff->main($text1, $text2);
        $timeStart = microtime(1);
        $memoryStart = memory_get_usage();
        $diff = new Diff();
        $diff->setTimeout(0);
        $diff->main($text1, $text2);
        $timeElapsed = microtime(1) - $timeStart;
        $memoryUsage = (memory_get_peak_usage() - $memoryStart) / 1024 / 1024;
        $this->assertLessThan(0.6, $timeElapsed);
        $this->assertLessThan(1, $memoryUsage);
        echo 'Elapsed time: ' . round($timeElapsed, 3) . PHP_EOL;
        echo 'Memory usage: ' . round($memoryUsage, 3) . PHP_EOL;
    }