Re: Distribution of longest common hash prefixes
- From
James Cloos <cloos@jhcloos.com>
- Date
- Apr 3, 2007, 17:04 UTC
- Message-ID
- <m3r6r1jsmq.fsf@lugabout.jhcloos.org>
- In-Reply-To
- <86r6r2isva.fsf@blue.stonehenge.com>
>>>>> "Randal" == Randal L Schwartz <merlyn@stonehenge.com> 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 <cloos@jhcloos.com> OpenPGP: 1024D/ED7DAEA6