All of lore.kernel.org
 help / color / mirror / Atom feed
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Eriksen <s022018@student.dtu.dk>, git@vger.kernel.org
Subject: Re: Distribution of longest common hash prefixes
Date: Mon, 02 Apr 2007 10:33:13 -0700	[thread overview]
Message-ID: <86r6r2isva.fsf@blue.stonehenge.com> (raw)
In-Reply-To: <86y7laitlz.fsf@blue.stonehenge.com> (Randal L. Schwartz's message of "Mon, 02 Apr 2007 10:17:12 -0700")

>>>>> "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>     }
Randal>   }
Randal>   $p = $_;
Randal>   $pcommon = $common;
Randal>   END { print "$_: $count[$_]" for 0..$#count }
Randal> '

And that's off by one on either end. :)

    git-rev-list --objects HEAD | sort | perl -lne '
      substr($_, 40) = "";
      if (defined $p) {
        ($p ^ $_) =~ /^(\0*)/;
        $common = length $1;
        if (defined $pcommon) {
          $count[$pcommon > $common ? $pcommon : $common]++;
        } else {
          $count[$common]++; # first item
        }
      }
      $p = $_;
      $pcommon = $common;
      END {
        $count[$common]++; # last item
        print "$_: $count[$_]" for 0..$#count;
      }
    '

Which now yields:

    0: 
    1: 
    2: 6
    3: 21155
    4: 15008
    5: 1232
    6: 90
    7: 
    8: 2

And *that* totals to 37493, which is the number of objects.  Yeay.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

  reply	other threads:[~2007-04-02 17:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-02 14:58 Distribution of longest common hash prefixes Peter Eriksen
2007-04-02 15:20 ` Linus Torvalds
2007-04-02 16:29   ` Randal L. Schwartz
2007-04-02 17:00     ` Linus Torvalds
2007-04-02 17:17       ` Randal L. Schwartz
2007-04-02 17:33         ` Randal L. Schwartz [this message]
2007-04-03 17:04           ` James Cloos
2007-04-03 17:11             ` Randal L. Schwartz
2007-04-03 17:21               ` Shawn O. Pearce
2007-04-03 17:50                 ` Linus Torvalds
2007-04-03 18:22                   ` Junio C Hamano
2007-04-03 19:27                     ` Linus Torvalds
2007-04-03 19:34                     ` Nicolas Pitre
2007-04-03 20:25                       ` Junio C Hamano
2007-04-03 20:39                         ` Nicolas Pitre
2007-04-03 23:08                           ` Olivier Galibert
2007-04-03 23:22                             ` Linus Torvalds
2007-04-04 21:03                   ` James Cloos
2007-04-02 17:18     ` James Cloos
2007-04-02 15:28 ` Peter Eriksen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86r6r2isva.fsf@blue.stonehenge.com \
    --to=merlyn@stonehenge.com \
    --cc=git@vger.kernel.org \
    --cc=s022018@student.dtu.dk \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.