Пример #1
0
    public function run()
    {
        $this->prepareTables();
        $repeats = $this->getRepeats();
        $value1 = 'string one';
        $value2 = 'string two';
        $value3 = 'string three';
        $bar = new CliProgressBar($repeats);
        for ($i = 1; $i <= $repeats; ++$i) {
            Timer::start();
            $sql = '
				INSERT INTO test (txt) VALUES
					(?),
					(?),
					(?)
			';
            Db::query($sql, [$value1, $value2, $value3]);
            Timer::stop();
            $bar->update($i);
        }
        $this->addResult('Real', Timer::get());
        PdoAdapter::instance()->getConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
        Timer::reset();
        $bar = new CliProgressBar($repeats);
        for ($i = 1; $i <= $repeats; ++$i) {
            Timer::start();
            $sql = '
				INSERT INTO test (txt) VALUES
					(?),
					(?),
					(?)
			';
            Db::query($sql, [$value1, $value2, $value3]);
            Timer::stop();
            $bar->update($i);
        }
        $this->addResult('Emulated', Timer::get());
        $this->cleanup();
    }