<?php // Create an in-memory SQLite database $db = new PDO('sqlite::memory:', null, null, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ]); $count = 10; // Measure time to insert $count integers $startInsert = microtime(true); $db->exec("CREATE TABLE numbers (id INTEGER PRIMARY KEY AUTOINCREMENT, value INTEGER NOT NULL)"); for ($i = 1; $i <= $count; $i++) { $db->exec("INSERT INTO numbers (value) VALUES ($i)"); } $insertTime = microtime(true) - $startInsert; $stmt = $db->query("SELECT sum(id) FROM numbers"); $records = $stmt->fetchAll(PDO::FETCH_COLUMN); print_r($records); // 55
You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).