git
[Ported from github.com/git/git] Sync with Git 2.56.1
Brought by drakestapleton
git / t / perf / generate-repo-p5413-connectivity-check.perl
| 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # Generate a fast-import stream for p5413 connectivity check benchmarks. |
| 4 | # |
| 5 | # Usage: generate-repo-p5413-connectivity-check.perl |
| 6 | # <dirs> <files_per_dir> <commits> [<hot_dirs>] [<files_per_commit>] |
| 7 | # |
| 8 | # Creates one initial commit with dirs*files_per_dir files, then |
| 9 | # <commits> additional commits each modifying <files_per_commit> |
| 10 | # files in directories chosen round-robin from 1..<hot_dirs>. |
| 11 | |
| 12 | use strict; |
| 13 | use warnings; |
| 14 | |
| 15 | my ($nd, $nf, $nc, $hot, $fpc) = @ARGV; |
| 16 | $hot = $nd if !$hot || $hot > $nd; |
| 17 | $fpc = 1 if !$fpc; |
| 18 | |
| 19 | sub data { |
| 20 | printf "data %d\n%s\n", length($_[0]), $_[0]; |
| 21 | } |
| 22 | |
| 23 | # Initial tree: one commit with nd*nf files. |
| 24 | printf "commit refs/heads/main\n"; |
| 25 | printf "committer perf <perf\@test.com> now\n"; |
| 26 | data("initial"); |
| 27 | for my $d (1..$nd) { |
| 28 | for my $f (1..$nf) { |
| 29 | printf "M 100644 inline d-%04d/f-%03d\n", $d, $f; |
| 30 | data(sprintf "%03d%03d", $d, $f); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | # Subsequent commits (auto-chained by fast-import). |
| 35 | for my $i (1..$nc) { |
| 36 | printf "commit refs/heads/main\n"; |
| 37 | printf "committer perf <perf\@test.com> now\n"; |
| 38 | data(sprintf "change-%03d", $i); |
| 39 | for my $j (0..$fpc-1) { |
| 40 | my $d = (($i + $j) % $hot) + 1; |
| 41 | printf "M 100644 inline d-%04d/f-001\n", $d; |
| 42 | data(sprintf "c%d-%d", $i, $j); |
| 43 | } |
| 44 | } |