Title: [189420] trunk/Source/WebInspectorUI
Revision
189420
Author
[email protected]
Date
2015-09-04 22:29:36 -0700 (Fri, 04 Sep 2015)

Log Message

Web Inspector: combine Test.html resources to make tests run faster
https://bugs.webkit.org/show_bug.cgi?id=148726

Reviewed by Timothy Hatcher.

In an attempt to make inspector tests run faster, always combine resources
on the Test.html page. This cuts down from 110+ resource loads to 5 loads.

To avoid name clashes, add the 'Combined' suffix to files that would clash
with uncombined Test resources, and add the 'Test' prefix when combining
or minifying files that would clash with production minification. So, it
would be possible for Main.html and Test.html to have different minified
versions of CodeMirror or other external libraries if they use different
subsets.

Combining is unlikely to make debugging tests more difficult, since almost
all test code is marshalled and eval'd into existence anyway.

* Configurations/WebInspectorUIFramework.xcconfig:
* Scripts/combine-resources.pl: Drive-by spelling.
(concatenateFiles):
(concatinateFiles): Deleted.
* Scripts/copy-user-interface-resources-dryrun.rb:
* Scripts/copy-user-interface-resources.pl:

    Drive-by spelling. Add a new code path for combining Test resources, which
    doesn't require minification or handling CSS, images, or most externals.

* WebInspectorUI.vcxproj/build-webinspectorui.pl:

    Always combine Test.html, but also ditto everything into place for
    engineering builds.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (189419 => 189420)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-09-05 05:29:24 UTC (rev 189419)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-09-05 05:29:36 UTC (rev 189420)
@@ -1,3 +1,38 @@
+2015-09-04  Brian Burg  <[email protected]>
+
+        Web Inspector: combine Test.html resources to make tests run faster
+        https://bugs.webkit.org/show_bug.cgi?id=148726
+
+        Reviewed by Timothy Hatcher.
+
+        In an attempt to make inspector tests run faster, always combine resources
+        on the Test.html page. This cuts down from 110+ resource loads to 5 loads.
+
+        To avoid name clashes, add the 'Combined' suffix to files that would clash
+        with uncombined Test resources, and add the 'Test' prefix when combining
+        or minifying files that would clash with production minification. So, it
+        would be possible for Main.html and Test.html to have different minified
+        versions of CodeMirror or other external libraries if they use different
+        subsets.
+
+        Combining is unlikely to make debugging tests more difficult, since almost
+        all test code is marshalled and eval'd into existence anyway.
+
+        * Configurations/WebInspectorUIFramework.xcconfig:
+        * Scripts/combine-resources.pl: Drive-by spelling.
+        (concatenateFiles):
+        (concatinateFiles): Deleted.
+        * Scripts/copy-user-interface-resources-dryrun.rb:
+        * Scripts/copy-user-interface-resources.pl:
+
+            Drive-by spelling. Add a new code path for combining Test resources, which
+            doesn't require minification or handling CSS, images, or most externals.
+
+        * WebInspectorUI.vcxproj/build-webinspectorui.pl:
+
+            Always combine Test.html, but also ditto everything into place for
+            engineering builds.
+
 2015-09-04  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Test Runtime.saveResult and $n values

Modified: trunk/Source/WebInspectorUI/Configurations/WebInspectorUIFramework.xcconfig (189419 => 189420)


--- trunk/Source/WebInspectorUI/Configurations/WebInspectorUIFramework.xcconfig	2015-09-05 05:29:24 UTC (rev 189419)
+++ trunk/Source/WebInspectorUI/Configurations/WebInspectorUIFramework.xcconfig	2015-09-05 05:29:36 UTC (rev 189420)
@@ -36,3 +36,8 @@
 COMBINE_INSPECTOR_RESOURCES_Debug = NO;
 COMBINE_INSPECTOR_RESOURCES_Release = NO;
 COMBINE_INSPECTOR_RESOURCES_Production = YES;
+
+COMBINE_TEST_RESOURCES = $(COMBINE_TEST_RESOURCES_$(CONFIGURATION));
+COMBINE_TEST_RESOURCES_Debug = YES;
+COMBINE_TEST_RESOURCES_Release = YES;
+COMBINE_TEST_RESOURCES_Production = YES;

Modified: trunk/Source/WebInspectorUI/Scripts/combine-resources.pl (189419 => 189420)


--- trunk/Source/WebInspectorUI/Scripts/combine-resources.pl	2015-09-05 05:29:24 UTC (rev 189419)
+++ trunk/Source/WebInspectorUI/Scripts/combine-resources.pl	2015-09-05 05:29:36 UTC (rev 189420)
@@ -1,5 +1,28 @@
 #!/usr/bin/perl -w
 
+# Copyright (C) 2015 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
 use strict;
 use Getopt::Long;
 use File::Basename;
@@ -42,11 +65,11 @@
 
 mkpath $outputDirectory;
 
-sub concatinateFiles($$$)
+sub concatenateFiles($$$)
 {
     my $filename = shift;
     my $tagExpression = shift;
-    my $concatinatedTag = shift;
+    my $concatenatedTag = shift;
     my $fileCount = 0;
 
     open OUT, ">", "$outputDirectory/$filename" or die "Can't open $outputDirectory/$filename: $!";
@@ -65,19 +88,19 @@
     # Don't use \s so we can control the newlines we consume.
     my $replacementExpression = "([\t ]*)" . $tagExpression . "[\t ]*\n+";
 
-    # Replace the first occurance with a token so we can inject the concatinated tag in the same place
+    # Replace the first occurance with a token so we can inject the concatenated tag in the same place
     # as the first file that got consolidated. This makes sure we preserve some order if there are other
     # items in the head that we didn't consolidate.
-    $headContents =~ s/$replacementExpression/$1%CONCATINATED%\n/i;
+    $headContents =~ s/$replacementExpression/$1%CONCATENATED%\n/i;
     $headContents =~ s/$replacementExpression//gi;
-    $headContents =~ s/%CONCATINATED%/$concatinatedTag/;
+    $headContents =~ s/%CONCATENATED%/$concatenatedTag/;
 }
 
 my $inputDirectoryPattern = "(?!External\/)[^\"]*";
 $inputDirectoryPattern = $inputDirectory . "\/[^\"]*" if $inputDirectory;
 
-concatinateFiles($outputStylesheetName, "<link rel=\"stylesheet\" href="" "<link rel=\"stylesheet\" href="" if defined $outputStylesheetName;
-concatinateFiles($outputScriptName, "<script src="" "<script src="" if defined $outputScriptName;
+concatenateFiles($outputStylesheetName, "<link rel=\"stylesheet\" href="" "<link rel=\"stylesheet\" href="" if defined $outputStylesheetName;
+concatenateFiles($outputScriptName, "<script src="" "<script src="" if defined $outputScriptName;
 
 $htmlContents =~ s/<head>.*<\/head>/<head>$headContents<\/head>/si;
 

Modified: trunk/Source/WebInspectorUI/Scripts/copy-user-interface-resources-dryrun.rb (189419 => 189420)


--- trunk/Source/WebInspectorUI/Scripts/copy-user-interface-resources-dryrun.rb	2015-09-05 05:29:24 UTC (rev 189419)
+++ trunk/Source/WebInspectorUI/Scripts/copy-user-interface-resources-dryrun.rb	2015-09-05 05:29:36 UTC (rev 189420)
@@ -1,5 +1,28 @@
 #!/usr/bin/ruby
 
+# Copyright (C) 2015 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
 require 'fileutils'
 require 'tmpdir'
 
@@ -28,6 +51,7 @@
   ENV["TARGET_BUILD_DIR"] = $output_directory
   ENV["UNLOCALIZED_RESOURCES_FOLDER_PATH"] = ""
   ENV["COMBINE_INSPECTOR_RESOURCES"] = "YES"
+  ENV["COMBINE_TEST_RESOURCES"] = "YES"
   exec COPY_USER_INTERFACE_RESOURCES_PATH
 
 end

Modified: trunk/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl (189419 => 189420)


--- trunk/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl	2015-09-05 05:29:24 UTC (rev 189419)
+++ trunk/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl	2015-09-05 05:29:36 UTC (rev 189420)
@@ -1,5 +1,28 @@
 #!/usr/bin/perl -w
 
+# Copyright (C) 2015 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
 use English;
 use File::Copy qw(copy);
 use File::Path qw(make_path remove_tree);
@@ -108,7 +131,6 @@
 my $codeMirrorLicense = readLicenseFile(File::Spec->catfile($codeMirrorPath, 'LICENSE'));
 my $esprimaLicense = readLicenseFile(File::Spec->catfile($esprimaPath, 'LICENSE'));
 my $eslintLicense = readLicenseFile(File::Spec->catfile($eslintPath, 'LICENSE'));
-
 make_path($protocolDir, $targetResourcePath);
 
 # Copy over dynamically loaded files from other frameworks, even if we aren't combining resources.
@@ -121,9 +143,11 @@
     ditto($uiRoot, $targetResourcePath);
 }
 
-if (defined $ENV{'COMBINE_INSPECTOR_RESOURCES'} && ($ENV{'COMBINE_INSPECTOR_RESOURCES'} eq 'YES')) {
-    my $combineResourcesCmd = File::Spec->catfile($scriptsRoot, 'combine-resources.pl');
+my $shouldCombineMain = defined $ENV{'COMBINE_INSPECTOR_RESOURCES'} && ($ENV{'COMBINE_INSPECTOR_RESOURCES'} eq 'YES');
+my $shouldCombineTest = defined $ENV{'COMBINE_TEST_RESOURCES'} && ($ENV{'COMBINE_TEST_RESOURCES'} eq 'YES');
+my $combineResourcesCmd = File::Spec->catfile($scriptsRoot, 'combine-resources.pl');
 
+if ($shouldCombineMain) {
     # Combine the _javascript_ and CSS files in Production builds into single files (Main.js and Main.css).
     system($combineResourcesCmd, '--input-html', File::Spec->catfile($uiRoot, 'Main.html'), '--derived-sources-dir', $derivedSourcesDir, '--output-dir', $derivedSourcesDir, '--output-script-name', 'Main.js', '--output-style-name', 'Main.css');
 
@@ -182,18 +206,18 @@
     system(qq("$python" "$cssMinScript" < "$derivedSourcesMainCSS" >> "$targetMainCSS")) and die "Failed to minify $derivedSourcesMainCSS: $!";
 
     # Minify the CodeMirror.js and CodeMirror.css files, appending to the license that was exported above.
-    my $derivedSouressCodeMirrorJS = File::Spec->catfile($derivedSourcesDir, 'CodeMirror.js');
+    my $derivedSourcesCodeMirrorJS = File::Spec->catfile($derivedSourcesDir, 'CodeMirror.js');
     my $derivedSourcesCodeMirrorCSS = File::Spec->catfile($derivedSourcesDir, 'CodeMirror.css');
-    system(qq("$python" "$jsMinScript" < "$derivedSouressCodeMirrorJS" >> "$targetCodeMirrorJS")) and die "Failed to minify $derivedSouressCodeMirrorJS: $!";
+    system(qq("$python" "$jsMinScript" < "$derivedSourcesCodeMirrorJS" >> "$targetCodeMirrorJS")) and die "Failed to minify $derivedSourcesCodeMirrorJS: $!";
     system(qq("$python" "$cssMinScript" < "$derivedSourcesCodeMirrorCSS" >> "$targetCodeMirrorCSS")) and die "Failed to minify $derivedSourcesCodeMirrorCSS: $!";
 
     # Minify the Esprima.js file, appending to the license that was exported above.
-    my $derivedSouressEsprimaJS = File::Spec->catfile($derivedSourcesDir, 'Esprima.js');
-    system(qq("$python" "$jsMinScript" < "$derivedSouressEsprimaJS" >> "$targetEsprimaJS")) and die "Failed to minify $derivedSouressEsprimaJS: $!";
+    my $derivedSourcesEsprimaJS = File::Spec->catfile($derivedSourcesDir, 'Esprima.js');
+    system(qq("$python" "$jsMinScript" < "$derivedSourcesEsprimaJS" >> "$targetEsprimaJS")) and die "Failed to minify $derivedSourcesEsprimaJS: $!";
 
     # Minify the ESLint.js file, appending to the license that was exported above.
-    my $derivedSouressESLintJS = File::Spec->catfile($derivedSourcesDir, 'ESLint.js');
-    system(qq("$python" "$jsMinScript" < "$derivedSouressESLintJS" >> "$targetESLintJS")) and die "Failed to minify $derivedSouressESLintJS: $!";
+    my $derivedSourcesESLintJS = File::Spec->catfile($derivedSourcesDir, 'ESLint.js');
+    system(qq("$python" "$jsMinScript" < "$derivedSourcesESLintJS" >> "$targetESLintJS")) and die "Failed to minify $derivedSourcesESLintJS: $!";
 
     # Copy over Main.html and the Images directory.
     copy($derivedSourcesMainHTML, File::Spec->catfile($targetResourcePath, 'Main.html'));
@@ -212,3 +236,34 @@
     # Keep the files separate for engineering builds.
     ditto($uiRoot, $targetResourcePath);
 }
+
+if ($shouldCombineTest) {
+    # Combine the _javascript_ files for testing into a single file (TestCombined.js ).
+    system($combineResourcesCmd, '--input-html', File::Spec->catfile($uiRoot, 'Test.html'), '--derived-sources-dir', $derivedSourcesDir, '--output-dir', $derivedSourcesDir, '--output-script-name', 'TestCombined.js', '--output-style-name', 'TestCombined.css');
+
+    my $derivedSourcesTestHTML = File::Spec->catfile($derivedSourcesDir, 'Test.html');
+    my $derivedSourcesTestJS = File::Spec->catfile($derivedSourcesDir, 'TestCombined.js');
+    # Combine the Esprima _javascript_ files for testing into a single file (Esprima.js).
+    system($combineResourcesCmd, '--input-dir', 'External/Esprima', '--input-html', $derivedSourcesTestHTML, '--input-html-dir', $uiRoot, '--derived-sources-dir', $derivedSourcesDir, '--output-dir', $derivedSourcesDir, '--output-script-name', 'TestEsprima.js');
+
+    # Export the license into TestCombined.js.
+    my $targetTestJS = File::Spec->catfile($targetResourcePath, 'TestCombined.js');
+    seedFile($targetTestJS, $inspectorLicense);
+
+    # Export the license into Esprima.js.
+    my $targetEsprimaJS = File::Spec->catfile($targetResourcePath, 'TestEsprima.js');
+    seedFile($targetEsprimaJS, $esprimaLicense);
+
+    # Append TestCombined.js to the license that was exported above.
+    system(qq(cat "$derivedSourcesTestJS" >> "$targetTestJS")) and die "Failed to append $derivedSourcesTestJS: $!";
+
+    # Append Esprima.js to the license that was exported above.
+    my $derivedSourcesEsprimaJS = File::Spec->catfile($derivedSourcesDir, 'TestEsprima.js');
+    system(qq(cat "$derivedSourcesEsprimaJS" >> "$targetEsprimaJS")) and die "Failed to append $derivedSourcesEsprimaJS: $!";
+
+    # Copy over Test.html.
+    copy($derivedSourcesTestHTML, File::Spec->catfile($targetResourcePath, 'Test.html'));
+
+    # Copy the Legacy directory.
+    ditto(File::Spec->catfile($uiRoot, 'Protocol', 'Legacy'), File::Spec->catfile($protocolDir, 'Legacy'));
+}

Modified: trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/build-webinspectorui.pl (189419 => 189420)


--- trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/build-webinspectorui.pl	2015-09-05 05:29:24 UTC (rev 189419)
+++ trunk/Source/WebInspectorUI/WebInspectorUI.vcxproj/build-webinspectorui.pl	2015-09-05 05:29:36 UTC (rev 189420)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-# Copyright (C) 2014 Apple Inc.  All rights reserved.
+# Copyright (C) 2014, 2015 Apple Inc.  All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -62,6 +62,7 @@
 
 $ENV{'UNLOCALIZED_RESOURCES_FOLDER_PATH'} = 'WebInspectorUI';
 
+$ENV{'COMBINE_TEST_RESOURCES'} = 'YES';
 if (($TARGET_BUILD_DIR =~ /Release/) || ($TARGET_BUILD_DIR =~ /Production/)) {
     $ENV{'COMBINE_INSPECTOR_RESOURCES'} = 'YES';
 } 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to