summaryrefslogtreecommitdiffstats
path: root/utils/testQuerySpeed.php
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
commit19985dbb8c0aa66dc4bf7905abc1148de909097d (patch)
tree2cd5a5d20d7e80fc2a51adf60d838d8a2c40999e /utils/testQuerySpeed.php
download1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.gz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.bz2
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.lz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.xz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.zst
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.zip
Diffstat (limited to 'utils/testQuerySpeed.php')
-rw-r--r--utils/testQuerySpeed.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/utils/testQuerySpeed.php b/utils/testQuerySpeed.php
new file mode 100644
index 0000000..6082864
--- /dev/null
+++ b/utils/testQuerySpeed.php
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * Test speed of query
+ * Uroš Podkrižnik 21.12.2017
+ */
+class testQuerySpeed {
+
+ function __construct() {
+
+ }
+
+ function test($sql_query = "SELECT id FROM srv_anketa", $loopnum = 1000) {
+ $microa = 0;
+ $microo = 0;
+ $microni = 0;
+ $micron = 0;
+ for ($i = 0; $i < $loopnum; $i++) {
+ $starta = microtime(true);
+ $sql_array = sisplet_query($sql_query, 'array');
+ foreach ($sql_array as $pair)
+ $res = $pair;
+ $enda = microtime(true);
+ $microa += ($enda - $starta);
+
+ $starto = microtime(true);
+ $sql_obj = sisplet_query($sql_query, 'obj');
+ foreach ($sql_obj as $pair)
+ $res = $pair;
+ $endo = microtime(true);
+ $microo += ($endo - $starto);
+
+ $startn = microtime(true);
+ $sql = sisplet_query($sql_query);
+ while ($row = mysqli_fetch_assoc($sql))
+ $res = $row;
+ $endn = microtime(true);
+ $microni += ($endn - $startn);
+
+ $startn = microtime(true);
+ $sql = sisplet_query($sql_query);
+ while ($row = mysqli_fetch_assoc($sql))
+ $res = $row;
+ $endn = microtime(true);
+ $micron += ($endn - $startn);
+ }
+ error_log('$microa ' . $microa);
+ error_log('$microo ' . $microo);
+ error_log('$microni ' . $microni);
+ error_log('$micron ' . $micron);
+ }
+
+}