#! /usr/bin/perl use Expect; $prune_age = -1; $warmup_secs = 10; $interval = 10; my $exp = Expect->spawn("psql", "postgres") or die "cannot execute psql: $!\n"; $exp->log_stdout(0); #print $exp "set track_catalog_cache_usage_interval to 1000;\n"; #$exp->expect(10, "postgres=#"); print $exp "set catalog_cache_prune_min_age to '${prune_age}s';\n"; $exp->expect(10, "postgres=#"); $starttime = time(); $count = 0; $mean = 0; $nexttime = $starttime + $warmup_secs; $firsttime = 1; while (1) { print $exp "begin; create temp table t1 (a int, b int, c int, d int, e int, f int, g int, h int, i int, j int) on commit drop; insert into t1 values (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); select * from t1; commit;\n"; $exp->expect(10, "postgres=#"); $count++; if (time() > $nexttime) { if ($firsttime) { $count = 0; $firsttime = 0; } elsif ($mean == 0) { $mean = $count; } else { $mean = $mean * 0.9 + $count * 0.1; } printf STDERR "%6d : %9.2f\n", $count, $mean if ($mean > 0); $count = 0; $nexttime += $interval; } }