⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 155383 in webkit


Ignore:
Timestamp:
Sep 9, 2013, 2:36:54 PM (13 years ago)
Author:
fpizlo@apple.com
Message:

Stress tests should test the jsc profiler (-p)
https://bugs.webkit.org/show_bug.cgi?id=121043

PerformanceTests/SunSpider:

Reviewed by Mark Hahnenberg.

Add a jsc-stress-test that tries to profile SunSpider.

  • profiler-test.yaml: Added.

Tools:

Reviewed by Mark Hahnenberg.

Add a runProfiler command that all tests could use. This requires profiler-test-helper,
which first runs the JS test and then tries the output with display-profiler-output.
But if any of the things required for this to work aren't present, we just do a simpler
test that just uses "-p".

Because I didn't want to pollute SunSpider with "@ runProfiler", I added the ability
to create test collections using a yaml file that specifies the test path and the
command to run.

  • Scripts/jsc-stress-test-helpers: Added.
  • Scripts/jsc-stress-test-helpers/profiler-test-helper: Added.
  • Scripts/run-javascriptcore-tests:
  • Scripts/run-jsc-stress-tests:
Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/PerformanceTests/SunSpider/ChangeLog

    r153824 r155383  
     12013-09-09  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Stress tests should test the jsc profiler (-p)
     4        https://bugs.webkit.org/show_bug.cgi?id=121043
     5
     6        Reviewed by Mark Hahnenberg.
     7       
     8        Add a jsc-stress-test that tries to profile SunSpider.
     9
     10        * profiler-test.yaml: Added.
     11
    1122013-08-08  Cosmin Truta  <ctruta@blackberry.com>
    213
  • trunk/Tools/ChangeLog

    r155373 r155383  
     12013-09-09  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Stress tests should test the jsc profiler (-p)
     4        https://bugs.webkit.org/show_bug.cgi?id=121043
     5
     6        Reviewed by Mark Hahnenberg.
     7       
     8        Add a runProfiler command that all tests could use. This requires profiler-test-helper,
     9        which first runs the JS test and then tries the output with display-profiler-output.
     10        But if any of the things required for this to work aren't present, we just do a simpler
     11        test that just uses "-p".
     12       
     13        Because I didn't want to pollute SunSpider with "//@ runProfiler", I added the ability
     14        to create test collections using a yaml file that specifies the test path and the
     15        command to run.
     16
     17        * Scripts/jsc-stress-test-helpers: Added.
     18        * Scripts/jsc-stress-test-helpers/profiler-test-helper: Added.
     19        * Scripts/run-javascriptcore-tests:
     20        * Scripts/run-jsc-stress-tests:
     21
    1222013-09-09  Zan Dobersek  <zdobersek@igalia.com>
    223
  • trunk/Tools/Scripts/run-javascriptcore-tests

    r155266 r155383  
    244244        "PerformanceTests/SunSpider/tests/sunspider-1.0",
    245245        "PerformanceTests/SunSpider/tests/v8-v6",
    246         "LayoutTests/fast/js/regress/script-tests"
     246        "LayoutTests/fast/js/regress/script-tests",
     247        "PerformanceTests/SunSpider/profiler-test.yaml"
    247248    );
    248249    if ($enableFTL) {
  • trunk/Tools/Scripts/run-jsc-stress-tests

    r155314 r155383  
    2626require 'getoptlong'
    2727require 'pathname'
     28require 'yaml'
     29
     30THIS_SCRIPT_PATH = Pathname.new(__FILE__).realpath
     31SCRIPTS_PATH = THIS_SCRIPT_PATH.dirname
     32raise unless SCRIPTS_PATH.basename.to_s == "Scripts"
     33raise unless SCRIPTS_PATH.dirname.basename.to_s == "Tools"
     34
     35HELPERS_PATH = SCRIPTS_PATH + "jsc-stress-test-helpers"
    2836
    2937$haveShellwords = false
     
    3745end
    3846
    39 def mysys(*cmd)
     47$canRunDisplayProfilerOutput = false
     48
     49begin
     50    require 'json'
     51    require 'highline'
     52    $canRunDisplayProfilerOutput = true
     53rescue => e
     54    $stderr.puts "Warning: did not find json or highline; some features will be disabled."
     55    $stderr.puts "Error: #{e.inspect}"
     56end
     57
     58def printCommandArray(*cmd)
    4059    begin
    4160        commandArray = cmd.each{|value| Shellwords.shellescape(value.to_s)}.join(' ')
     
    4463    end
    4564    $stderr.puts ">> #{commandArray}"
     65end
     66
     67def mysys(*cmd)
     68    printCommandArray(*cmd)
    4669    raise "Command failed: #{$?.inspect}" unless system(*cmd)
    4770end
     
    5477$outputDir = Pathname.new("results")
    5578$parallel = ($haveShellwords and numProcessors > 1)
     79$verbosity = 0
    5680
    5781def usage
     
    6286    puts "--[no-]parallel         Run in parallel, or not. Default is #{$parallel}."
    6387    puts "--output-dir     (-o)   Path where to put results. Default is #{$outputDir}."
     88    puts "--verbose        (-v)   Print more things while running."
    6489    puts "--help           (-h)   Print this message."
    6590    exit 1
     
    7196               ['--parallel', GetoptLong::NO_ARGUMENT],
    7297               ['--no-parallel', GetoptLong::NO_ARGUMENT],
    73                ['--output-dir', '-o', GetoptLong::REQUIRED_ARGUMENT]).each {
     98               ['--output-dir', '-o', GetoptLong::REQUIRED_ARGUMENT],
     99               ['--verbose', '-v', GetoptLong::NO_ARGUMENT]).each {
    74100    | opt, arg |
    75101    case opt
     
    86112    when '--no-parallel'
    87113        $parallel = false
     114    when '--verbose'
     115        $verbosity += 1
    88116    end
    89117}
     
    114142            | outp |
    115143            outp.puts "echo Running #{Shellwords.shellescape(@name)}"
    116             outp.puts("(cd #{Shellwords.shellescape(@directory.to_s)} && " +
    117                       @arguments.map{|v| Shellwords.shellescape(v)}.join(' ') +
    118                       ") || #{failCommand}")
    119         }
    120     end
     144            cmd = ("(cd #{Shellwords.shellescape(@directory.to_s)} && " +
     145                   @arguments.map{|v| Shellwords.shellescape(v)}.join(' ') +
     146                   ") || #{failCommand}")
     147            if $verbosity >= 1
     148                outp.puts "echo #{Shellwords.shellescape(cmd)}"
     149            end
     150            outp.puts cmd
     151        }
     152    end
     153end
     154
     155$uniqueFilenameCounter = 0
     156def uniqueFilename(extension)
     157    payloadDir = $outputDir + "_payload"
     158    Dir.mkdir payloadDir unless payloadDir.directory?
     159    result = payloadDir.realpath + "temp-#{$uniqueFilenameCounter}#{extension}"
     160    $uniqueFilenameCounter += 1
     161    result
     162end
     163
     164def addRunCommand(kind, command)
     165    $runlist << Plan.new($benchmarkDirectory, command, "#{$collectionName}/#{$benchmark}.#{kind}")
    121166end
    122167
    123168def run(kind, *options)
    124     $runlist << Plan.new($collection,
    125                          [$jscPath.to_s] + options + [$benchmark],
    126                          "#{$collectionName}/#{$benchmark}.#{kind}")
     169    addRunCommand(kind, [$jscPath.to_s] + options + [$benchmark.to_s])
    127170end
    128171
     
    149192def runFTLEager
    150193    run("ftl-eager", "--useExperimentalFTL=true", *EAGER_OPTIONS)
     194end
     195
     196def runProfiler
     197    profilerOutput = uniqueFilename(".json")
     198    if $haveShellwords and $canRunDisplayProfilerOutput
     199        addRunCommand("profiler", ["ruby", (HELPERS_PATH + "profiler-test-helper").to_s, (SCRIPTS_PATH + "display-profiler-output").to_s, profilerOutput.to_s, $jscPath.to_s, "-p", profilerOutput.to_s, $benchmark.to_s])
     200    else
     201        run("profiler-simple", "-p", profilerOutput.to_s)
     202    end
    151203end
    152204
     
    167219end
    168220
    169 collectionNames = {}
    170 
    171221Dir.mkdir($outputDir) unless $outputDir.directory?
    172222begin
     
    177227$outputDir = $outputDir.realpath
    178228
    179 ARGV.each {
    180     | collection |
    181     $collection = Pathname.new(collection)
    182     outerDir = $collection.dirname
    183     name = $collection.basename
     229def allJSFiles(path)
     230    if path.file?
     231        [path]
     232    else
     233        result = []
     234        Dir.foreach(path) {
     235            | filename |
     236            next unless filename =~ /\.js$/
     237            next unless (path + filename).file?
     238            result << path + filename
     239        }
     240        result
     241    end
     242end
     243
     244# Returns [collectionPath, collectionName]
     245def simplifyCollectionName(collectionNames, collectionPath)
     246    outerDir = collectionPath.dirname
     247    name = collectionPath.basename
    184248    lastName = name
    185     while lastName.to_s =~ /test/
    186         lastName = outerDir.basename
    187         name = lastName + name
    188         outerDir = outerDir.dirname
    189     end
    190     $collectionName = name.to_s
     249    if collectionPath.directory?
     250        while lastName.to_s =~ /test/
     251            lastName = outerDir.basename
     252            name = lastName + name
     253            outerDir = outerDir.dirname
     254        end
     255    end
     256    collectionName = name.to_s
    191257    toAdd = 1
    192     while collectionNames[$collectionName]
    193         $collectionName = File.basename(name.to_s) + "-#{toAdd}"
     258    while collectionNames[collectionName]
     259        collectionName = File.basename(name.to_s) + "-#{toAdd}"
    194260        toAdd += 1
    195261    end
    196     collectionNames[$collectionName] = true
     262    collectionNames[collectionName] = true
     263    [collectionPath, collectionName]
     264end
     265
     266def prepareCollection(name)
    197267    dir = $outputDir
    198     name.each_filename {
     268    Pathname.new(name).each_filename {
    199269        | filename |
    200270        dir = dir + filename
    201271        Dir.mkdir(dir) unless dir.directory?
    202272    }
    203 
    204     Dir.foreach($collection) {
    205         | benchmark |
    206         next unless benchmark =~ /\.js$/
    207         next unless ($collection + benchmark).file?
     273end
     274
     275collectionNames = {}
     276
     277ARGV.each {
     278    | collection |
     279    collection, collectionName = simplifyCollectionName(collectionNames, Pathname.new(collection))
     280   
     281    if collection.file?
     282        subCollectionNames = {}
     283        YAML::load(IO::read(collection)).each {
     284            | entry |
     285            path = collection.dirname + entry["path"]
     286           
     287            subCollection, subCollectionName = simplifyCollectionName(subCollectionNames, path)
     288           
     289            $collection = subCollection
     290            $collectionName = (Pathname.new(collectionName) + subCollectionName).to_s
     291           
     292            prepareCollection($collectionName)
     293           
     294            allJSFiles(path).each {
     295                | path |
     296               
     297                path = path.realpath
     298               
     299                $benchmark = path.basename
     300                $benchmarkDirectory = path.dirname
     301               
     302                eval entry["cmd"]
     303            }
     304        }
     305    else
     306        prepareCollection(collectionName)
    208307       
    209         $benchmark = benchmark
    210        
    211         didRun = false
    212         File.open($collection + benchmark) {
    213             | inp |
    214             inp.each_line {
    215                 | line |
    216                 next unless line =~ /^\/\/@/
    217                 eval $~.post_match
    218                 didRun = true
     308        $collection = collection
     309        $collectionName = collectionName
     310        $benchmarkDirectory = $collection
     311        allJSFiles($collection).each {
     312            | path |
     313           
     314            $benchmark = path.basename
     315           
     316            didRun = false
     317            File.open($collection + $benchmark) {
     318                | inp |
     319                inp.each_line {
     320                    | line |
     321                    next unless line =~ /^\/\/@/
     322                    eval $~.post_match
     323                    didRun = true
     324                }
    219325            }
    220         }
    221        
    222         defaultRun unless didRun
    223     }
     326           
     327            defaultRun unless didRun
     328        }
     329    end
    224330}
    225331
     
    344450       
    345451        Dir.chdir(plan.directory) {
     452            if $verbosity >= 1
     453                printCommandArray(*plan.arguments)
     454            end
    346455            if system(*plan.arguments)
    347456                puts "OK."
Note: See TracChangeset for help on using the changeset viewer.