<commit_before><?php
/**
 * JBZoo Path
 *
 * This file is part of the JBZoo CCK package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package   Path
 * @license   MIT
 * @copyright Copyright (C) JBZoo.com,  All rights reserved.
 * @link      https://github.com/JBZoo/Path
 */

namespace JBZoo\PHPUnit;

use JBZoo\Path\Path;
use Symfony\Component\Filesystem\Filesystem;

/**
 * Class PerformanceTest
 * @package JBZoo\Path
 */
class PerformanceTest extends PHPUnit
{
    protected $_max = 1000000;

    public function testLeakMemoryCreate()
    {
        if ($this->isXDebug()) {
            return;
        }

        $this->startProfiler();

        for ($i = 0; $i < $this->_max; $i++) {
            // Your code start
            $path = Path::getInstance(__FUNCTION__);
            $path->add(__DIR__ . DS . mt_rand());
            unset($path);
            // Your code finish
        }

        alert($this->loopProfiler($this->_max), 'Create - min');
    }

    public function testBenchmark()
    {
        $fs = new Filesystem();

        runBench(array(
            'JBZoo\Path' => function () use ($fs) {

                $dirName = mt_rand();
                $path    = __DIR__ . DS . $dirName;
                $fs->mkdir($path);

                // start
                $Path = Path::getInstance('JBZooPath');
                $Path->add(__DIR__ . DS . $dirName);
                $result = $Path->get('default:');
                // end

                $fs->remove($path);

                return $result;
            },
            'RealPath'   => function () use ($fs) {
                $dirName = mt_rand();
                $path    = __DIR__ . DS . $dirName;
                $fs->mkdir($path);

                // start
                $result = realpath($path);
                // end

                $fs->remove($path);

                return $result;
            },
        ), array('count' => 500, 'name' => 'Path lib'));
    }
}<commit_msg>remove old test<commit_after><?php
/**
 * JBZoo Path
 *
 * This file is part of the JBZoo CCK package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package   Path
 * @license   MIT
 * @copyright Copyright (C) JBZoo.com,  All rights reserved.
 * @link      https://github.com/JBZoo/Path
 */

namespace JBZoo\PHPUnit;

use JBZoo\Path\Path;
use Symfony\Component\Filesystem\Filesystem;

/**
 * Class PerformanceTest
 * @package JBZoo\Path
 */
class PerformanceTest extends PHPUnit
{
    public function testBenchmark()
    {
        $fs = new Filesystem();

        runBench(array(
            'JBZoo\Path' => function () use ($fs) {

                $dirName = mt_rand();
                $path    = __DIR__ . DS . $dirName;
                $fs->mkdir($path);

                // start
                $Path = Path::getInstance('JBZooPath');
                $Path->set(Path::DEFAULT_ALIAS, __DIR__ . DS . $dirName);
                $result = $Path->get('default:');
                // end

                $fs->remove($path);

                return $result;
            },
            'RealPath'   => function () use ($fs) {
                $dirName = mt_rand();
                $path    = __DIR__ . DS . $dirName;
                $fs->mkdir($path);

                // start
                $result = realpath($path);
                // end

                $fs->remove($path);

                return $result;
            },
        ), array('count' => 500, 'name' => 'Path lib'));
    }
}
{'fraction_non_alphanumeric': 0.1370767960363336, 'fraction_numerical': 0.0038535645472061657, 'mean_word_length': 1.5341701534170153, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4707609', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1028, 'n_words': 256}