Wednesday, April 4, 2012

MySQL Benchmark

How my server is performing ?
===========================

No matter the result of the expression, the result of benchmark() will always be 0. The purpose of benchmark() is not to retrieve the result of the expression but to see how long it takes to repeat the expression for a specific number of times. For example, the following command executes the expression 10 + 10 one million times:

mysql> SELECT BENCHMARK(1000000,10+10);
+--------------------------+
| BENCHMARK(1000000,10+10) |
+--------------------------+
|            0 |
+--------------------------+
1 row in set (0.14 sec)

1 comment:

  1. We have the similar thing in Perl:

    for example:
    use Benchmark qw(:all) ;
    timethis ($count, "code");
    $results = timethese( -1, { a => "++\$i", b => "\$i *= 2" } ) ;

    enjoy!!!!!!!

    ReplyDelete