Permalink
Browse files

Remove TODO, move to GitHub issue tracker

Remove benchmarks, move to node-mysql-bindings-benchmarks
  • Loading branch information...
1 parent 2dd7bef commit 2d5df070b42c10994631c426d250ffe1c017db1c @Sannis committed Aug 25, 2010
Showing with 0 additions and 384 deletions.
  1. +0 −37 TODO
  2. +0 −148 benchmark/benchmark.js
  3. +0 −190 benchmark/benchmark.php
  4. +0 −9 benchmark/benchmark_node_vs_php.sh
View
37 TODO
@@ -1,37 +0,0 @@
-Things to do or at least think about doing in the future
-
-
-Synchronouse bindings
----------------------
- * Implement all methods of 'statement' class
- * Think over the names of methods, not much different
- from the original MySQL API functions, but with grouping,
- like for multiquery methods:
- * MultiMoreResults()
- * MultiNextResult()
- * MultiRealQuery()
-
-
-Testing
--------
- * Write unittests for each function
- * Write functional tests for specific queries an situations
-
-
-Documentation
--------------
- * Write doxygen comments for all source code
- * Write API documentation with descriptions for all public methods
- * Write some usable examples
-
-
-Asynchrony
-----------
- * Make a list of methods to be implemented in non-blocking version
- * Implement them to version 0.2.0
-
-Also
-----
-
-See API TODO in docs/api_todo.md file
-
View
@@ -1,148 +0,0 @@
-#!/usr/bin/env node
-/*
-Copyright (C) 2010, Oleg Efimov <efimovov@gmail.com>
-
-See license text in LICENSE file
-*/
-
-var host = "localhost",
- user = "test",
- password = "",
- database = "test",
- test_table = "test_table",
-
- // Operations count for continuous benchmarks
- reconnects_count = 100000,
- escapes_count = 10000000,
- inserts_count = 200000,
- selects_count = 100,
- rows_to_select = 10,
-
- sys = require("sys"),
- mysql_libmysqlclient = require("../mysql-libmysqlclient"),
-
- start,
- finish,
-
- conn;
-
-
-// Utility functions
-
-function round2(number) {
- return Math.round(number * 100) / 100;
-}
-
-function doBenchmark(title, prepare_function, execute_function) {
- var start,
- finish,
- data;
-
- if (typeof prepare_function === "function") {
- data = prepare_function();
-
- start = new Date();
- execute_function(data);
- finish = new Date();
- } else {
- start = new Date();
- execute_function();
- finish = new Date();
- }
-
- sys.puts(title + ": " + round2((finish.valueOf() - start.valueOf()) / 1000) + "s");
-}
-
-
-// Initialize connection for benchmarks
-
-sys.puts("Init...");
-
-conn = mysql_libmysqlclient.createConnection(host, user, password, database);
-
-start = new Date();
-
-
-// Benchmark 1: connect and disconnect
-
-doBenchmark("Connect and disconnect(" + reconnects_count + ")", 0, function () {
- var i;
- for (i = 0; i < reconnects_count; i += 1) {
- conn.close();
- conn.connect(host, user, password, database);
- }
-});
-
-
-// Benchmark 2: escape string
-
-doBenchmark("Escape string(" + escapes_count + ")", 0, function () {
- // A bit utility code
- var string_to_escape = "test\\string\nwith\rmany\"symbols'and\x00nulls",
- escaped_string,
- i;
-
- for (i = 0; i < escapes_count; i += 1) {
- escaped_string = conn.escape(string_to_escape);
- }
-});
-
-
-// Benchmark 3: inserts
-
-doBenchmark("Inserts(" + inserts_count + ")", function () {
- conn.query("DROP TABLE IF EXISTS " + test_table + ";");
- conn.query("CREATE TABLE " + test_table + " (autoincrement_id BIGINT NOT NULL AUTO_INCREMENT, random_number INT(8) NOT NULL, random_boolean BOOLEAN NOT NULL, PRIMARY KEY (autoincrement_id));");
-
- var rows = [],
- i;
-
- for (i = 0; i < inserts_count; i += 1) {
- rows[i] = {
- 'random_number': Math.round(Math.random() * 1000000),
- 'random_boolean': (Math.random() > 0.5) ? 1 : 0
- };
- }
-
- return rows;
-}, function (rows) {
- var i;
- for (i = 0; i < inserts_count; i += 1) {
- conn.query("INSERT INTO " + test_table + " (random_number, random_boolean) VALUES ('" + rows[i].random_number + "', '" + rows[i].random_boolean + "');");
- }
-});
-
-
-// Benchmark 3: selects
-
-doBenchmark("Selects(" + selects_count + ", " + rows_to_select + ")", function () {
- var limits = [],
- i;
-
- for (i = 0; i < selects_count; i += 1) {
- limits[i] = Math.round(Math.random() * (inserts_count - rows_to_select));
- }
-
- return limits;
-}, function (limits) {
- var rows = new Array(selects_count),
- res,
- i;
-
- for (i = 0; i < selects_count; i += 1) {
- res = conn.query("SELECT * FROM " + test_table + " ORDER BY RAND() LIMIT " + limits[i] + ", " + rows_to_select + ";", 1);
- rows[i] = res.fetchAll();
- }
-});
-
-
-// Finish benchmarks
-
-finish = new Date();
-
-sys.puts("Finish.");
-
-conn.close();
-
-sys.puts("Full time: " + round2((finish.valueOf() - start.valueOf()) / 1000) + "s");
-
View
@@ -1,190 +0,0 @@
-#!/usr/bin/env php
-<?php
-/*
-Copyright (C) 2010, Oleg Efimov <efimovov@gmail.com>
-
-See license text in LICENSE file
-*/
-
-$host = "localhost";
-$user = "test";
-$password = "";
-$database = "test";
-$test_table = "test_table";
-
-
-$reconnects_count = 100000;
-$escapes_count = 10000000;
-$inserts_count = 200000;
-$selects_count = 100;
-$rows_to_select = 10;
-
-
-$conn;
-
-
-// Utility functions
-
-function sys_puts($str)
-{
- print $str."\n";
-}
-
-function my_random()
-{
- return rand()/getrandmax();
-}
-
-function do_benchmark($title, $prepare_function, $execute_function)
-{
- $start;
- $finish;
-
- if( $prepare_function )
- {
- $data = call_user_func($prepare_function);
-
- $start = microtime(true);
- call_user_func($execute_function, $data);
- $finish = microtime(true);
- }
- else
- {
- $start = microtime(true);
- call_user_func($execute_function);
- $finish = microtime(true);
- }
-
- sys_puts($title.": ".round(($finish - $start), 2)."s");
-}
-
-
-// Benchmarking functions
-
-function do_benchmark_connect_and_disconnect()
-{
- global $conn, $reconnects_count, $host, $user, $password, $database;
-
- for( $i = 0; $i < $reconnects_count; $i++ )
- {
- mysql_close($conn);
- $conn = mysql_connect($host, $user, $password);
- mysql_select_db($database , $conn);
- }
-
-}
-
-function do_benchmark_escape_string()
-{
- global $conn, $escapes_count;
-
- // A bit utility code
- $string_to_escape = "test\\string\nwith\rmany\"symbols'and\x00nulls";
- $escaped_string;
-
- for( $i = 1; $i <= $escapes_count; $i++ )
- {
- $escaped_string = mysql_real_escape_string($string_to_escape, $conn);
- }
-}
-
-function do_benchmark_insert_prepare()
-{
- global $conn, $test_table, $inserts_count;
-
- mysql_query("DROP TABLE IF EXISTS ".$test_table.";", $conn);
- mysql_query("CREATE TABLE ".$test_table." (autoincrement_id BIGINT NOT NULL AUTO_INCREMENT, random_number INT(8) NOT NULL, random_boolean BOOLEAN NOT NULL, PRIMARY KEY (autoincrement_id));", $conn);
-
- $rows = array();
-
- for( $i = 0; $i < $inserts_count; $i++ )
- {
- $rows[$i] = array( 'random_number' => intval(my_random()*1000000), 'random_boolean' => ( (my_random() > 0.5) ? 1 : 0 ) );
- }
-
- return $rows;
-}
-
-function do_benchmark_insert($rows)
-{
- global $conn, $test_table, $inserts_count;
-
- for( $i = 0; $i < $inserts_count; $i++ )
- {
- mysql_query("INSERT INTO ".$test_table." (random_number, random_boolean) VALUES ('".$rows[$i]['random_number']."', '".$rows[$i]['random_boolean']."');", $conn);
- }
-}
-
-function do_benchmark_select_prepare()
-{
- global $conn, $selects_count, $inserts_count, $rows_to_select;
-
- $limits = array();
-
- for( $i = 0; $i < $selects_count; $i++ )
- {
- $limits[$i] = intval(my_random()*($inserts_count-$rows_to_select));
- }
-
- return $limits;
-}
-
-function do_benchmark_select($limits)
-{
- global $conn, $test_table, $selects_count, $rows_to_select;
-
- $rows = array();
-
- for( $i = 0; $i < $selects_count; $i++ )
- {
- $r = mysql_query("SELECT * FROM ".$test_table." ORDER BY RAND() LIMIT ".$limits[$i].", ".$rows_to_select.";", $conn);
-
- $rows[$i] = array();
-
- while($row = mysql_fetch_array($r))
- {
- $rows[$i][] = $row;
- }
- }
-}
-
-// Initialize connection for benchmarks
-
-sys_puts("Init...");
-
-$conn = mysql_connect($host, $user, $password);
-mysql_select_db($database, $conn);
-
-$start = microtime(true);
-
-
-// Benchmark 1: connect and disconnect
-
-do_benchmark("Connect and disconnect(".$reconnects_count.")", 0, "do_benchmark_connect_and_disconnect");
-
-
-// Benchmark 2: escape string
-
-do_benchmark("Escape string(".$escapes_count.")", 0, "do_benchmark_escape_string");
-
-
-// Benchmark 3: inserts
-
-do_benchmark("Inserts(".$inserts_count.")", "do_benchmark_insert_prepare", "do_benchmark_insert");
-
-
-// Benchmark 3: selects
-
-do_benchmark("Selects(".$selects_count.", ".$rows_to_select.")", "do_benchmark_select_prepare", "do_benchmark_select");
-
-
-// Finish benchmarks
-
-$finish = microtime(true);
-
-sys_puts("Finish.");
-
-mysql_close($conn);
-
-sys_puts("Full time: ".round(($finish - $start), 2)."s");
-
@@ -1,9 +0,0 @@
-#/usr/bin/sh
-
-echo "NodeJS synchronouse MySQL bindings benchmark:"
-./benchmark.js
-echo
-
-echo "PHP MySQL bindings benchmark:"
-./benchmark.php
-echo

0 comments on commit 2d5df07

Please sign in to comment.