[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / tools / perf / page_sets / blob_workshop.py
blob319f0267d1eb1a4e081c1a9188f8e18fc5caecf7
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 from telemetry.page import page as page_module
6 from telemetry.page import page_test as page_test
7 from telemetry import story
10 NUM_BLOB_MASS_CREATE_READS = 15
13 class BlobCreateThenRead(page_module.Page):
15 def __init__(self, write_method, blob_sizes, page_set):
16 super(BlobCreateThenRead, self).__init__(
17 url='file://blob/blob-workshop.html',
18 page_set=page_set,
19 name='blob-create-read-' + write_method)
20 self._blob_sizes = blob_sizes
22 def RunPageInteractions(self, action_runner):
23 action_runner.ExecuteJavaScript('disableUI = true;')
25 for size_bytes in self._blob_sizes:
26 with action_runner.CreateInteraction('Action_CreateAndReadBlob',
27 repeatable=True):
28 action_runner.ExecuteJavaScript(
29 'createAndRead(' + str(size_bytes) + ');')
30 action_runner.WaitForJavaScriptCondition(
31 'doneReading === true || errors', 60)
33 errors = action_runner.EvaluateJavaScript('errors')
34 if errors:
35 raise page_test.Failure('Errors on page: ' + ', '.join(errors))
38 class BlobMassCreate(page_module.Page):
39 def __init__(self, write_method, blob_sizes, page_set):
40 super(BlobMassCreate, self).__init__(
41 url='file://blob/blob-workshop.html',
42 page_set=page_set,
43 name='blob-mass-create-' + write_method)
44 self._blob_sizes = blob_sizes
46 def RunPageInteractions(self, action_runner):
47 action_runner.ExecuteJavaScript('disableUI = true;')
49 # Add blobs
50 for size_bytes in self._blob_sizes:
51 with action_runner.CreateInteraction('Action_CreateBlob',
52 repeatable=True):
53 action_runner.ExecuteJavaScript('createBlob(' + str(size_bytes) + ');')
55 # Read blobs
56 for _ in range(0, NUM_BLOB_MASS_CREATE_READS):
57 with action_runner.CreateInteraction('Action_ReadBlobs',
58 repeatable=True):
59 action_runner.ExecuteJavaScript('readBlobsSerially();')
60 action_runner.WaitForJavaScriptCondition(
61 'doneReading === true || errors', 60)
63 errors = action_runner.EvaluateJavaScript('errors')
64 if errors:
65 raise page_test.Failure('Errors on page: ' + ', '.join(errors))
68 class BlobWorkshopPageSet(story.StorySet):
69 """The BlobWorkshop page set."""
71 def __init__(self):
72 super(BlobWorkshopPageSet, self).__init__()
73 self.AddStory(
74 BlobMassCreate('2Bx200', [2] * 200, self))
75 self.AddStory(
76 BlobMassCreate('1KBx200', [1024] * 200, self))
77 self.AddStory(
78 BlobMassCreate('150KBx200', [150 * 1024] * 200, self))
79 self.AddStory(
80 BlobMassCreate('1MBx200', [1024 * 1024] * 200, self))
81 self.AddStory(
82 BlobMassCreate('10MBx30', [10 * 1024 * 1024] * 30, self))
83 # http://crbug.com/510815
84 #self.AddStory(
85 # BlobMassCreate('80MBx5', [80 * 1024 * 1024] * 5, self))
87 self.AddStory(BlobCreateThenRead('2Bx200', [2] * 200, self))
88 self.AddStory(BlobCreateThenRead('1KBx200', [1024] * 200, self))
89 self.AddStory(
90 BlobCreateThenRead('150KBx200', [150 * 1024 - 1] * 200, self))
91 self.AddStory(BlobCreateThenRead('1MBx200', [1024 * 1024] * 200, self))
92 self.AddStory(
93 BlobCreateThenRead('10MBx30', [10 * 1024 * 1024] * 30, self))
94 self.AddStory(
95 BlobCreateThenRead('80MBx5', [80 * 1024 * 1024] * 5, self))