Last active
August 29, 2015 14:04
-
-
Save jaxbot/6b3828d0e385de4e6278 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
import "time" | |
func main() { | |
timestart := time.Now() | |
for c := 0; c < 100000000; c++ { | |
bubble() | |
} | |
timeend := time.Now(); | |
fmt.Print(timeend.Sub(timestart)); | |
} | |
func bubble() { | |
array := [...]int16{3,4,1,3,5,1,92,2,4124,424,52,12} | |
for i := 0; i < len(array); i++ { | |
for y := 0; y < len(array) - 1; y++ { | |
if array[y+1] < array[y] { | |
t := array[y] | |
array[y] = array[y+1] | |
array[y+1] = t | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var starttime = new Date().getTime(); | |
for (var c = 0; c < 100000000; c++) { | |
bubble(); | |
} | |
function bubble() { | |
var array = [3,4,1,3,5,1,92,2,4124,424,52,12]; | |
for (var i = 0; i < array.length; i++) { | |
for (var y = 0; y < array.length - 1; y++) { | |
if (array[y+1] < array[y]) { | |
var t = array[y]; | |
array[y] = array[y + 1]; | |
array[y + 1] = t; | |
} | |
} | |
} | |
} | |
console.log(new Date().getTime() - starttime); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"database/sql" | |
"fmt" | |
_ "github.com/go-sql-driver/mysql" | |
"time" | |
) | |
func main() { | |
timestart := time.Now() | |
db, err := sql.Open("mysql", "root@/recalls") | |
if err != nil { | |
panic(err.Error()) | |
} | |
defer db.Close() | |
for c := 0; c < 100; c++ { | |
query, err := db.Query("SELECT RECORD_ID FROM recalls WHERE MAKETXT = 'BMW'") | |
if err != nil { | |
panic(err.Error()) | |
} | |
var col1 int | |
query.Next(); | |
err = query.Scan(&col1); | |
if err != nil { | |
panic(err.Error()) | |
} | |
defer query.Close() | |
} | |
timeend := time.Now() | |
fmt.Print(timeend.Sub(timestart)) | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mysql = require("mysql-libmysqlclient"); | |
var starttime = new Date().getTime(); | |
connection = mysql.createConnectionSync(); | |
connection.connectSync("127.0.0.1", "root", "", "recalls"); | |
var c = 0; | |
for (var i = 0; i < 100; i++) { | |
connection.query("SELECT RECORD_ID FROM recalls WHERE MAKETXT = 'BMW'", function(err,res) { | |
res.fetchAll(function(err,res) { | |
c++; | |
if (c > 99) { | |
console.log(new Date().getTime() - starttime); | |
} | |
}); | |
}); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$time = microtime(true); | |
$mysqli = new mysqli("127.0.0.1", "root", "", "recalls"); | |
for ($i = 0; $i < 100; $i++) { | |
$res = $mysqli->query("SELECT RECORD_ID FROM recalls WHERE MAKETXT = 'BMW'"); | |
$row = $res->fetch_assoc(); | |
} | |
echo microtime(true) - $time; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment