#! /usr/bin/perl #================================================================ # mapreporter # Measure elapsed time of map utilities #================================================================ use strict; use warnings; use Time::HiRes qw(gettimeofday); use constant { RECNUM => 1000000, TESTCOUNT => 20, REMOVETOP => 2, REMOVEBOTTOM => 8, }; my @commands = ( "./maptest tcmap " . RECNUM, "./maptest tctree " . RECNUM, "./maptest stlmap " . RECNUM, "./maptest stlmmap " . RECNUM, "./maptest stlset " . RECNUM, "./maptest gnuhash " . RECNUM, "./maptest ggldh " . RECNUM, "./maptest gglsh " . RECNUM, "./maptest tcmap -rd " . RECNUM, "./maptest tctree -rd " . RECNUM, "./maptest stlmap -rd " . RECNUM, "./maptest stlmmap -rd " . RECNUM, "./maptest stlset -rd " . RECNUM, "./maptest gnuhash -rd " . RECNUM, "./maptest ggldh -rd " . RECNUM, "./maptest gglsh -rd " . RECNUM, ); my @table; foreach my $command (@commands){ system("sync ; sync"); my @result; for(my $i = 0; $i < TESTCOUNT; $i++){ my $stime = gettimeofday(); system("$command >/dev/null 2>&1"); $stime = gettimeofday() - $stime; printf("%s\t%d\t%0.5f\n", $command, $i + 1, $stime); push(@result, $stime); } @result = sort { $a <=> $b } @result; for(my $i = 0; $i < REMOVETOP; $i++){ shift(@result); } for(my $i = 0; $i < REMOVEBOTTOM; $i++){ pop(@result); } my $sum = 0; foreach my $result (@result){ $sum += $result; } my $avg = $sum / scalar(@result); push(@table, [$command, $avg]); } printf("\n\nRESULT\n"); foreach my $row (@table){ printf("%s\t%0.5f\n", $$row[0], $$row[1]); } printf("\n"); # END OF FILE