]>
git.proxmox.com Git - pve-manager.git/blob - bin/pveperf
5 use Time
::HiRes
qw( usleep ualarm gettimeofday tv_interval );
6 use Net
::DNS
::Resolver
;
9 print STDERR
"usage: $0 [PATH]\n";
13 my $path = $ARGV[0] || '/';
17 # free pagecache,dentries,inode cache
18 if (-f
'/proc/sys/vm/drop_caches') {
19 system ("echo 3 > /proc/sys/vm/drop_caches");
26 open (TMP
, "/proc/cpuinfo");
28 while (my $line = <TMP
>) {
29 if ($line =~ m/^bogomips\s*:\s*(\d+\.\d+)\s*$/) {
36 printf "CPU BOGOMIPS: %.2f\n", $bogomips;
41 my $starttime = [gettimeofday
];
48 my $str = int(rand(1000000)) . time();
49 if ($str =~ m/(.+)123.?123/) {
51 $elapsed = tv_interval
($starttime);
56 printf "REGEX/SECOND: %d\n", $count;
64 my $dir = "$basedir/ptest.$$";
70 my $data = ('A' x
4000) . "\n";
72 my $starttime = [gettimeofday
];
77 for ($count=1;;$count++) {
80 my $filename = "$dir/tf_$m.dat";
82 open (TMP
, ">$filename") || die "open failed";
86 File
::Sync
::fsync
(\
*TMP
);
90 $elapsed = tv_interval
($starttime);
94 my $sps = $count /$elapsed; # fsync per second
96 printf "FSYNCS/SECOND: %.2f\n", $sps;
101 system ("rm -rf $dir");
107 my ($rootdev, $hdsize) = @_;
111 open (ROOTHD
, "<$rootdev") || die "unable to open HD";
113 my $starttime = [gettimeofday
];
118 for ($count=1;;$count++) {
120 my $pos = int (rand (int($hdsize/512))) * 512;
122 sysseek (ROOTHD
, $pos, 0);
124 (sysread (ROOTHD
, $readbuf, 512) == 512) || die "read failed";
126 $elapsed = tv_interval
($starttime);
128 last if $elapsed > 3;
133 my $rps = $count /$elapsed; # blocks per second
134 my $ast = (1000/$rps);
135 printf "AVERAGE SEEK TIME: %.2f ms\n", $ast;
143 my $starttime = [gettimeofday
];
149 open (ROOTHD
, "<$rootdev") || die "unable to open HD";
154 my $c = sysread (ROOTHD
, $readbuf, 2 * 1024 *1024);
155 die "read failed" if $c < 0;
159 $elapsed = tv_interval
($starttime);
161 last if $elapsed > 3;
166 my $bps = $bytes /($elapsed * 1024 * 1024); # MB per second
167 printf "BUFFERED READS: %.2f MB/sec\n", $bps;
171 my ($resolv, $dns) = @_;
173 if (my $a = $resolv->send ($dns, 'A')) {
174 foreach my $rra ($a->answer) {
175 if ($rra->type eq 'A') {
176 return $rra->address;
196 #$dnsargs{nameservers} = [ qw (208.67.222.222) ];
197 #$dnsargs{nameservers} = [ qw (127.0.0.1) ];
199 my $resolv = Net
::DNS
::Resolver-
>new (%dnsargs);
201 my $starttime = [gettimeofday
];
206 my $uid = time() . int(rand(1000000));
207 my $domain = "nonexistent$uid.com";
209 for ($count=1;;$count++) {
211 my $hid = int(rand(1000000));
212 my $hname = "test${hid}.$domain";
213 get_address
($resolv, $hname);
214 $elapsed = tv_interval
($starttime);
216 last if ($count > 100) || ($elapsed > 3);
219 printf "DNS EXT: %0.2f ms\n", ($elapsed * 1000)/$count;
221 my $resolv_conf = `cat /etc/resolv.conf`;
222 ($domain) = $resolv_conf =~ m/^search\s+(\S+)\s*$/mg;
225 $starttime = [gettimeofday
];
228 for ($count=1;;$count++) {
230 my $hid = int(rand(1000000));
231 my $hname = "test${hid}.$domain";
232 get_address
($resolv, $hname);
233 $elapsed = tv_interval
($starttime);
235 last if ($count > 100) || ($elapsed > 3);
238 printf "DNS INT: %0.2f ms (%s)\n",
239 ($elapsed * 1000)/ $count, $domain;
246 my $hd = `df -P '$path'`;
248 my ($rootdev, $hdo_total, $hdo_used, $hdo_avail) = $hd =~
249 m/^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+\S+\s+.*$/mg;
252 my $hdsize = $hdo_total*1024;
253 printf "HD SIZE: %.2f GB ($rootdev)\n", ($hdsize / (1024*1024*1024));
255 if ($rootdev =~ m
|^/dev/|) {
256 test_read
($rootdev);
258 test_seektime
($rootdev, $hdsize);
263 test_fsync
($path) if $hdo_avail;
273 pveperf - the Proxmox benchmark
281 Tries to gather some CPU/Hardisk performance data on the hardisk
282 mounted at PATH (/ is used as default)
284 * CPU BOGOMIPS: bogomips sum of all CPUs
286 * REGEX/SECOND: regular expressions per second (perl performance test), should be above 300000
288 * HD SIZE: harddisk size
290 * BUFFERED READS: simple HD read test. Modern HDs should reach
293 * AVERAGE SEEK TIME: tests average seek time. Fast SCSI HDs reach values < 8 milliseconds. Common IDE/SATA disks get values from 15 to 20 ms.
295 * FSYNCS/SECOND: value should be greater than 200 (you should
296 enable 'write back' cache mode on you RAID controller - needs a battery
297 backed cache (BBWC)).
299 * DNS EXT: average time to resolve an external DNS name
301 * DNS INT: average time to resolve a local DNS name