Re: Distribution of longest common hash prefixes
From: James Cloos <hidden>
Date: 2016-06-15 22:43:02
quoted
quoted
quoted
quoted
"Randal" == Randal L Schwartz [off-list ref] writes:
Randal> git-rev-list --objects HEAD | sort | perl -lne '
Randal> substr($_, 40) = "";
Randal> if (defined $p) {
Randal> ($p ^ $_) =~ /^(\0*)/;
Randal> $common = length $1;
Randal> if (defined $pcommon) {
Randal> $count[$pcommon > $common ? $pcommon : $common]++;
Randal> } else {
Randal> $count[$common]++; # first item
Randal> }
Randal> }
Randal> $p = $_;
Randal> $pcommon = $common;
Randal> END {
Randal> $count[$common]++; # last item
Randal> print "$_: $count[$_]" for 0..$#count;
Randal> }
Randal> '
With that version the kernel gives:
0:
1:
2:
3: 565
4: 288450
5: 139080
6: 10699
7: 700
8: 32
9: 2
Adding in $_ = unpack("B*",pack("H*",$_));
to the script, to do the work on bits, gives:
14:
15: 565
16: 14723
17: 66765
18: 107838
19: 99124
20: 67367
21: 39238
22: 21503
23: 10972
24: 5591
25: 2927
26: 1472
27: 709
28: 382
29: 166
30: 98
31: 54
32: 20
33: 6
34: 2
35: 4
36:
37: 2
-JimC
--
James Cloos [off-list ref] OpenPGP: 1024D/ED7DAEA6