WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
VERIFIED FIXED
25517
build-webkit script should print build time at end
https://bugs.webkit.org/show_bug.cgi?id=25517
Summary
build-webkit script should print build time at end
Jeff Johnson
Reported
2009-05-02 01:17:15 PDT
Unless you have a supercomputer, WebKit takes a long time to build. Thus, it would be both interesting and useful if the build-webkit script finished by printing the amount of time it took to run.
Attachments
Patch for bug 25517 : build-webkit script should print build time at end
(2.07 KB, patch)
2009-09-01 13:32 PDT
,
Laurent Cerveau
ddkilzer
: review-
Details
Formatted Diff
Diff
Patch for bug 25517 revision 2: use of subroutine for time computation, coding guidelines
(2.33 KB, patch)
2009-09-02 04:47 PDT
,
Laurent Cerveau
ddkilzer
: review-
Details
Formatted Diff
Diff
Patch for bug 25517 revision 3: better coding guideline, nice formatting for build time
(2.41 KB, patch)
2009-09-02 13:37 PDT
,
Laurent Cerveau
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Laurent Cerveau
Comment 1
2009-09-01 13:32:17 PDT
Created
attachment 38883
[details]
Patch for
bug 25517
: build-webkit script should print build time at end N/A
David Kilzer (:ddkilzer)
Comment 2
2009-09-01 21:11:52 PDT
Comment on
attachment 38883
[details]
Patch for
bug 25517
: build-webkit script should print build time at end This is a great first patch! Some comments below:
> +2009-09-01 Laurent Cerveau <
lcerveau@me.com
> > + > + Reviewed by NOBODY (OOPS!). > + > + <
http://webkit.org/b/25517
> build-webkit script should print build time at end > + > + * Scripts/build-webkit: > + Added startTime and endTime variable so that the build time is computed and printed as > + part of the build message. Proper display formatting (hours, min, secs).
Lines should be indented by exactly 8 spaces. There appears to be 9 spaces or 2 tabs used above.
> +my $endTime = time; > +my $buildTime = $endTime - $startTime; > + > +my $buildHours = ($buildTime - $buildTime % 3600)/3600; > +my $buildMins = (($buildTime - $buildHours*3600) - ($buildTime - $buildHours*3600) %60)/60; > +my $buildSecs = $buildTime - $buildHours*3600 - $buildMins*60;
This logic would be best in it's own function that takes ($endTime - $startTime) as input and returns a formatted string. Maybe call it formatBuildTime(). I would also leave off hour calculations and only calculate minutes and seconds. Most modern hardware builds WebCore in much less than an hour. Please add spaces before and after all operators (*, %, /, +, -).
> + > +
There should only be one blank line here.
> print "\n"; > print "===========================================================\n"; > -print " WebKit is now built. To run $launcherName with this newly-built\n"; > -print " code, use the \"$launcherPath\" script.\n"; > +print " WebKit is now built ($buildHours:$buildMins:$buildSecs). \n"; > +print " To run $launcherName with this newly-built code, use the\n"; > +print " \"$launcherPath\" script.\n"; > print "===========================================================\n";
This is fine, but a single $buildTime string from formatBuildTime() would replace $buildHours:$buildMins:$buildSecs. r- to fix the above issues. Thanks!
Laurent Cerveau
Comment 3
2009-09-02 04:45:21 PDT
Here is a second version of the patch. A few comments - I did keep the possibility to display the hour but only if it is superior to 1 (on my Macbook , it namely is sometimes at the limit) - I did put the subRoutine in the build-webkit script. Not sure however that this is where it makes the most sense (maybe a separate utilities file?).
Laurent Cerveau
Comment 4
2009-09-02 04:47:19 PDT
Created
attachment 38923
[details]
Patch for
bug 25517
revision 2: use of subroutine for time computation, coding guidelines
David Kilzer (:ddkilzer)
Comment 5
2009-09-02 07:10:19 PDT
Comment on
attachment 38923
[details]
Patch for
bug 25517
revision 2: use of subroutine for time computation, coding guidelines The ChangeLog looks good! I think one more patch should do it. Most of the issues are simply following coding style used in other Perl scripts in the WebKit project. (Sorry, I missed some of these on the first review.)
> +my $startTime = time;
Since 'time' here is a subroutine call, please add empty parenthesis: time()
> +# Formatting routine to display build time
The comment isn't necessary; I think the name of the subroutine is self-explanatory.
> +sub formatBuildTime > +{
New subroutines added to Perl script should have the number of parameters declared: sub formatBuildTime($) { The subroutine itself should appear (alphabetically--although this would be the first one) after the last "exit 0;" statement in the file. Also, this subroutine should be declared at the top of the script with its parameter list (it should come after the 'use' statements but before any global variables): use POSIX; +sub formatBuildTime($); my $originalWorkingDirectory = getcwd();
> + my $buildTime = $_[0];
This is normally written using the @_ array in other Perl scripts: my ($buildTime) = @_;
> + my $buildHours = ($buildTime - $buildTime % 3600) / 3600;
This would be easier to read using: my $buildHours = int($buildTime / 3600);
> + my $buildMins = (($buildTime - $buildHours * 3600) - ($buildTime - $buildHours*3600) % 60) / 60;
Similarly: my $buildMins = int(($buildTime - $buildHours * 3600) / 60)
> + if ($buildHours) { > + my $result = $buildHours,':',$buildMins,':',$buildSecs; > + } else { > + my $result = $buildMins,':',$buildSecs; > + }
A few items here: - WebKit usually prefers to use an "early return" instead of an if/else block in these cases. - WebKit prefers explicit return statements for values. This code uses implicit return values, e.g., the last statement executed, and declares a $result variable that's never really used. - The formatBuildTime() subroutine should really return a string instead of a list of strings. - The minutes and seconds values should be zero-padded so you have times like "1:01:05" instead of "1:1:5". - I think it would be nice to add "h", "m" and "s" suffixes to the time values to make them easier to read: "18m:02s", "1h:01m:05s". Here's how that code might look: if ($buildHours) { return sprintf("%dh:%02dm:%02ds", $buildHours, $buildMins, $buildSecs); } return sprintf("%02dm:%02ds", $buildMins, $buildSecs);
> +my $endTime = time;
This should use "time()" since it's a subroutine call.
> -print " WebKit is now built. To run $launcherName with this newly-built\n"; > -print " code, use the \"$launcherPath\" script.\n"; > +print " WebKit is now built (", &formatBuildTime($endTime - $startTime), "). \n"; > +print " To run $launcherName with this newly-built code, use the\n"; > +print " \"$launcherPath\" script.\n";
Instead of calling the subroutine inside the print statement, let's set a variable outside the "print" statements (no need to use the '&' modifier here to invoke the subroutine): my $buildTime = formatBuildTime($endTime - $startTime); Then we can just use the variable in the print statement (like the others already do):
> +print " WebKit is now built ($buildTime). \n";
r- for the remaining issues. Thanks!
Laurent Cerveau
Comment 6
2009-09-02 13:37:56 PDT
Created
attachment 38940
[details]
Patch for
bug 25517
revision 3: better coding guideline, nice formatting for build time Thanks for the comments! (Very useful learning experience). All should be here now..
Eric Seidel (no email)
Comment 7
2009-09-02 14:01:54 PDT
Comment on
attachment 38940
[details]
Patch for
bug 25517
revision 3: better coding guideline, nice formatting for build time Patch was not marked as a patch (checkbox). :) In the future you might consider using tools like 'bugzilla-tool post-diff 25517' which will automatically post diffs to bugs and mark them as patches and mark them as needing review.
Eric Seidel (no email)
Comment 8
2009-09-02 14:03:45 PDT
Comment on
attachment 38940
[details]
Patch for
bug 25517
revision 3: better coding guideline, nice formatting for build time it seems a little silly that we have support for printing hours. If a build ever takes an hour, I'd be concerned. :) If it did, it might be just as clear to say "61 minutes" instead of 1 hr 1 minute. :)
Eric Seidel (no email)
Comment 9
2009-09-02 14:08:25 PDT
Welcome to WebKit, btw!
David Kilzer (:ddkilzer)
Comment 10
2009-09-02 19:18:53 PDT
Comment on
attachment 38940
[details]
Patch for
bug 25517
revision 3: better coding guideline, nice formatting for build time Great! r=me
Eric Seidel (no email)
Comment 11
2009-09-02 19:31:49 PDT
Comment on
attachment 38940
[details]
Patch for
bug 25517
revision 3: better coding guideline, nice formatting for build time Clearing flags on attachment: 38940 Committed
r48004
: <
http://trac.webkit.org/changeset/48004
>
Eric Seidel (no email)
Comment 12
2009-09-02 19:31:53 PDT
All reviewed patches have been landed. Closing bug.
Jeff Johnson
Comment 13
2009-09-03 19:13:49 PDT
Thanks! I've verified this patch. Now I know that I need to buy a much faster computer.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug