Ejemplo n.º 1
0
function test_mysql(&$result, $settings)
{
    $timeStart = microtime(true);
    $link = mysql_connect($settings['db.host'], $settings['db.user'], $settings['db.pw']);
    $result['benchmark']['mysql']['connect'] = timer_diff($timeStart);
    //$arr_return['sysinfo']['mysql_version'] = '';
    mysql_select_db($link, $settings['db.name']);
    $result['benchmark']['mysql']['select_db'] = timer_diff($timeStart);
    $dbResult = mysql_query($link, 'SELECT VERSION() as version;');
    $arr_row = mysql_fetch_array($dbResult);
    $result['sysinfo']['mysql_version'] = $arr_row['version'];
    $result['benchmark']['mysql']['query_version'] = timer_diff($timeStart);
    $query = "SELECT BENCHMARK(1000000,ENCODE('hello',RAND()));";
    $dbResult = mysql_query($link, $query);
    $result['benchmark']['mysql']['query_benchmark'] = timer_diff($timeStart);
    mysql_close($link);
    $result['benchmark']['mysql']['total'] = timer_diff($timeStart);
    return $result;
}
Ejemplo n.º 2
0
function test_wordpress()
{
    //create dummy text to insert into database
    $dummytextseed = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque sollicitudin iaculis libero id pellentesque. Donec sodales nunc id lorem rutrum molestie. Duis ac ornare diam. In hac habitasse platea dictumst. Donec nec mi ipsum. Aenean dictum imperdiet erat, at lacinia mi ultrices ut. Phasellus quis nibh ornare, pulvinar dui sit amet, venenatis arcu. Suspendisse eget vehicula ligula, et placerat sapien. Cras enim erat, scelerisque sit amet tellus vel, tempor venenatis risus. In ultricies tristique ante, eu lobortis leo. Cras ullamcorper eleifend libero, quis sollicitudin massa venenatis a. Vestibulum sed pellentesque urna, nec consectetur nulla. Vestibulum sodales purus metus, non scelerisque.";
    $dummytext = "";
    for ($x = 0; $x < 100; $x++) {
        $dummytext .= str_shuffle($dummytextseed);
    }
    //start timing wordpress mysql functions
    $time_start = microtime(true);
    global $wpdb;
    $table = $wpdb->prefix . 'options';
    $optionname = 'wpperformancetesterbenchmark_';
    $count = 250;
    for ($x = 0; $x < $count; $x++) {
        //insert
        $data = array('option_name' => $optionname . $x, 'option_value' => $dummytext);
        $wpdb->insert($table, $data);
        //select
        $select = "SELECT option_value FROM {$table} WHERE option_name='{$optionname}" . $x . "'";
        $wpdb->get_var($select);
        //update
        $data = array('option_value' => $dummytextseed);
        $where = array('option_name' => $optionname . $x);
        $wpdb->update($table, $data, $where);
        //delete
        $where = array('option_name' => $optionname . $x);
        $wpdb->delete($table, $where);
    }
    $time = timer_diff($time_start);
    $queries = $count * 4 / $time;
    return array('time' => $time, 'queries' => $queries);
}