From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johan Herland Subject: [PATCHv5 07/14] t3302-notes-index-expensive: Speed up create_repo() Date: Tue, 08 Sep 2009 04:26:55 +0200 Message-ID: <1252376822-6138-8-git-send-email-johan@herland.net> References: <1252376822-6138-1-git-send-email-johan@herland.net> Mime-Version: 1.0 Content-Type: TEXT/PLAIN Content-Transfer-Encoding: 7BIT Cc: git@vger.kernel.org, johan@herland.net, Johannes.Schindelin@gmx.de, trast@student.ethz.ch, tavestbo@trolltech.com, git@drmicha.warpmail.net, chriscool@tuxfamily.org, spearce@spearce.org To: gitster@pobox.com X-From: git-owner@vger.kernel.org Tue Sep 08 04:28:31 2009 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1MkqRa-0005lE-7G for gcvg-git-2@lo.gmane.org; Tue, 08 Sep 2009 04:28:30 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753452AbZIHC1b (ORCPT ); Mon, 7 Sep 2009 22:27:31 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753435AbZIHC13 (ORCPT ); Mon, 7 Sep 2009 22:27:29 -0400 Received: from smtp.getmail.no ([84.208.15.66]:34059 "EHLO get-mta-out02.get.basefarm.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753404AbZIHC12 (ORCPT ); Mon, 7 Sep 2009 22:27:28 -0400 Received: from mx.getmail.no ([10.5.16.4]) by get-mta-out02.get.basefarm.net (Sun Java(tm) System Messaging Server 7.0-0.04 64bit (built Jun 20 2008)) with ESMTP id <0KPM00CYOS5ULI90@get-mta-out02.get.basefarm.net> for git@vger.kernel.org; Tue, 08 Sep 2009 04:27:30 +0200 (MEST) Received: from localhost.localdomain ([84.215.102.95]) by get-mta-in03.get.basefarm.net (Sun Java(tm) System Messaging Server 7.0-0.04 64bit (built Jun 20 2008)) with ESMTP id <0KPM0072GS5GQN30@get-mta-in03.get.basefarm.net> for git@vger.kernel.org; Tue, 08 Sep 2009 04:27:30 +0200 (MEST) X-PMX-Version: 5.5.5.374460, Antispam-Engine: 2.7.1.369594, Antispam-Data: 2009.9.8.21525 X-Mailer: git-send-email 1.6.4.304.g1365c.dirty In-reply-to: <1252376822-6138-1-git-send-email-johan@herland.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Creating repos with 10/100/1000/10000 commits and notes takes a lot of time. However, using git-fast-import to do the job is a lot more efficient than using plumbing commands to do the same. This patch decreases the overall run-time of this test on my machine from ~3 to ~1 minutes. Signed-off-by: Johan Herland Acked-by: Johannes Schindelin --- t/t3302-notes-index-expensive.sh | 74 ++++++++++++++++++++++++-------------- 1 files changed, 47 insertions(+), 27 deletions(-) diff --git a/t/t3302-notes-index-expensive.sh b/t/t3302-notes-index-expensive.sh index 0ef3e95..ee84fc4 100755 --- a/t/t3302-notes-index-expensive.sh +++ b/t/t3302-notes-index-expensive.sh @@ -16,30 +16,50 @@ test -z "$GIT_NOTES_TIMING_TESTS" && { create_repo () { number_of_commits=$1 nr=0 - parent= test -d .git || { git init && - tree=$(git write-tree) && - while [ $nr -lt $number_of_commits ]; do - test_tick && - commit=$(echo $nr | git commit-tree $tree $parent) || - return - parent="-p $commit" - nr=$(($nr+1)) - done && - git update-ref refs/heads/master $commit && - { - GIT_INDEX_FILE=.git/temp; export GIT_INDEX_FILE; - git rev-list HEAD | cat -n | sed "s/^[ ][ ]*/ /g" | - while read nr sha1; do - blob=$(echo note $nr | git hash-object -w --stdin) && - echo $sha1 | sed "s/^/0644 $blob 0 /" - done | git update-index --index-info && - tree=$(git write-tree) && + ( + while [ $nr -lt $number_of_commits ]; do + nr=$(($nr+1)) + mark=$(($nr+$nr)) + notemark=$(($mark+1)) + test_tick && + cat < $GIT_COMMITTER_DATE +data <> note_commit + done && test_tick && - commit=$(echo notes | git commit-tree $tree) && - git update-ref refs/notes/commits $commit - } && + cat < $GIT_COMMITTER_DATE +data < output && - i=1 && - while [ $i -le $count ]; do - echo " $(($count-$i))" && - echo " note $i" && - i=$(($i+1)); + i=$count && + while [ $i -gt 0 ]; do + echo " commit #$i" && + echo " note for commit #$i" && + i=$(($i-1)); done > expect && - git diff expect output + test_cmp expect output } cat > time_notes << \EOF -- 1.6.4.304.g1365c.dirty