summaryrefslogtreecommitdiffstats
path: root/bm
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2026-04-19 11:28:11 +0800
committerSadeep Madurange <sadeep@asciimx.com>2026-04-19 11:28:11 +0800
commit7bc027bf79730a5a7dce523818d46081dc01f4d6 (patch)
treedd8620fefe7ab9efcede58a50cc59c975830d807 /bm
parent273e15c652f678e7a0946263fcf129764b38bda3 (diff)
downloadurn-7bc027bf79730a5a7dce523818d46081dc01f4d6.tar.gz
BM: detailed report.
Diffstat (limited to 'bm')
-rw-r--r--bm/bm_size.pl74
1 files changed, 48 insertions, 26 deletions
diff --git a/bm/bm_size.pl b/bm/bm_size.pl
index af8c8e7..42f7dad 100644
--- a/bm/bm_size.pl
+++ b/bm/bm_size.pl
@@ -15,24 +15,39 @@ my $urn_bin = abs_path(File::Spec->catfile("..", "urn"));
my $seed_bin = abs_path("seed.pl");
my $bm_repo = "bm_repo";
-# Storage for results: $results{Action}{Tool} = "metrics string"
my %results;
my @actions = qw(Status Add Commit);
+# Helper to count inodes (files/folders) in the metadata directory
+sub count_inodes {
+ my $dir = shift;
+ return 0 unless -d $dir;
+ my $count = `find $dir | wc -l`;
+ $count =~ s/\s+//g;
+ return $count;
+}
+
+# Helper to get folder size in KB
+sub get_size {
+ my $dir = shift;
+ return 0 unless -d $dir;
+ my $size = `du -sk $dir`;
+ $size =~ /^(\d+)/;
+ return $1 || 0;
+}
+
sub run_benchmark {
my ($tool_name) = @_;
-
- print "Running $tool_name...\n";
+ print "Benchmarking $tool_name...\n";
- # 1. Seed
+ # 1. Seed the directory
system("perl $seed_bin $files $depth > /dev/null 2>&1") == 0 or die "Seeding failed";
chdir($bm_repo) or die "Could not enter $bm_repo: $!";
- # 2. Init
+ my $meta_dir = ($tool_name eq "URN") ? ".urn" : ".git";
my $init_cmd = ($tool_name eq "URN") ? "perl $urn_bin init" : "git init";
system("$init_cmd > /dev/null 2>&1");
- # 3. Timed Actions
my %cmds = (
"Status" => ($tool_name eq "URN") ? "perl $urn_bin status" : "git status",
"Add" => ($tool_name eq "URN") ? "perl $urn_bin add ." : "git add .",
@@ -41,16 +56,21 @@ sub run_benchmark {
foreach my $action (@actions) {
my $cmd = $cmds{$action};
- # Extract just real time and max rss for the table
+ # Capture time metrics via STDERR
my $raw = `(/usr/bin/time -l $cmd > /dev/null) 2>&1`;
- # Parse specific metrics: Real time and Max RSS
+ # Parse OpenBSD 'time -l' output
my ($real) = $raw =~ /(\d+\.\d+)\s+real/;
my ($rss) = $raw =~ /(\d+)\s+maximum resident set size/;
-
- $results{$action}{$tool_name} = {
- time => $real // "N/A",
- mem => $rss ? sprintf("%.2f MB", $rss / 1024 / 1024) : "N/A"
+ my ($maj) = $raw =~ /(\d+)\s+page faults caused by physical I\/O/;
+ my ($min) = $raw =~ /(\d+)\s+page reclaims by virtual memory/;
+
+ $results{$action}{$tool_name} = {
+ real => $real // "0.00",
+ rss => $rss ? sprintf("%.1fM", $rss / 1024 / 1024) : "0M",
+ fault => sprintf("%d/%d", $maj // 0, $min // 0),
+ inodes => count_inodes($meta_dir),
+ disk => get_size($meta_dir) . "K",
};
}
@@ -58,33 +78,35 @@ sub run_benchmark {
remove_tree($bm_repo) if -d $bm_repo;
}
-# Run the sequence
+# Run sequence
run_benchmark("URN");
run_benchmark("GIT");
-# --- Generate the report ---
-my $out_file = "BM_COMPARE_${files}_${depth}.txt";
+# --- Final Report Formatting ---
+my $out_file = "BM_ULTIMATE_${files}_${depth}.txt";
open(my $res, '>', $out_file) or die $!;
-my $header = sprintf("%-12s | %-18s | %-18s", "ACTION", "URN (Time/Mem)", "GIT (Time/Mem)");
-my $sep = "-" x length($header);
+my $fmt = "%-8s | %-32s | %-32s\n";
+my $sep = ("-" x 78);
-print $res "BENCHMARK: $files files, $depth depth\n";
-print $res "$sep\n$header\n$sep\n";
+print $res "BENCHMARK: $files files @ $depth depth\n$sep\n";
+printf $res $fmt, "ACTION", "URN (Time/RSS/Faults/Inodes/Size)", "GIT (Time/RSS/Faults/Inodes/Size)";
+print $res "$sep\n";
foreach my $action (@actions) {
my $u = $results{$action}{"URN"};
my $g = $results{$action}{"GIT"};
-
- printf $res "%-12s | %6ss / %-8s | %6ss / %-8s\n",
- $action,
- $u->{time}, $u->{mem},
- $g->{time}, $g->{mem};
-}
+ printf $res "%-8s | %5ss %5s %7s %4s %5s | %5ss %5s %7s %4s %5s\n",
+ $action,
+ $u->{real}, $u->{rss}, $u->{fault}, $u->{inodes}, $u->{disk},
+ $g->{real}, $g->{rss}, $g->{fault}, $g->{inodes}, $g->{disk};
+}
print $res "$sep\n";
close($res);
+# Use PAGER for output
print "\nComparison complete! Results saved to $out_file\n";
-system("cat $out_file");
+my $pager = $ENV{PAGER} || 'less';
+system("$pager $out_file");