Skip to main content

Posts

Showing posts with the label benchmarking

howto benchmark javascript code?

Is there a package that helps me benchmark JS code ? Im not referring the Firebug and such tools. I need to compare 2 different JS functions that I have implemented. Im very familiar with perl's Benchmark ( http://search.cpan.org/~tty/kurila-1.19_0/lib/Benchmark.pm ) module and Im looking for something similar in javascript. Is the emphasis on benchmarking the JS code overboard ? Can I get away with timing just one run of the functions ? Source: Tips4all

PHP is slower than it should be

Originally, I posted this on ServerFault ... but perhaps it is more of a PHP lingual question. I have a server with Dual Xeon Quad Core L5420 running at 2.5GHz. I've been optimizing my server, and have come to my final bottleneck: PHP. My very simple PHP script: ./test.php <?php print_r(posix_getpwuid(posix_getuid())); My not-so-scientific-because-they-don't-pay-attention-to-thread-locking-but-scientific-enough-to-give-me-a-reasonable-multithreaded-requests-per-second-result scripts: ./benchmark-php #!/bin/bash if [ -z $1 ]; then LIMIT=10 else LIMIT=$1 fi if [ -z $2 ]; then SCRIPT="index.php" else SCRIPT=$2 fi START=$(date +%s.%N) COUNT=0 while (( $COUNT < $LIMIT )) do php $SCRIPT > /dev/null COUNT=$(echo "$COUNT + 1" | bc) done END=$(date +%s.%N) DIFF=$(echo "$END - $START" | bc) REQS_PER_SEC=$(echo "scale=2; $COUNT / $DIFF" | bc) echo $REQS_PER_SEC ./really-benchmark-php #!/bin/bash if [ -z $1 ]; then