#!/usr/bin/perl $replacements = 2500000; ## Set number of replacements to make $startTime = time; ## Determine start time for ($j = 0; $j < $replacements; $j++) { ## Perform set number of replacements $text = "Hello World"; ## Reset string $text =~s/World/Canada/; ## Replace 'World' with 'Canada' } $finishTime = time; ## Determine finish time $timeTaken = $finishTime - $startTime; ## Determine total time taken in seconds $rps = int($replacements/$timeTaken); ## Determine the number of replacements per second print "Content-type:text/html\n\n"; ## Output the results to the web browser print "
Computation Speed Test Results
Made $replacements replacements in $timeTaken seconds. That's $rps replacements per second!
To repeat the test, just click refresh. Otherwise, you can close this window.
";