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
.page
import page_set
as page_set_module
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',
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',
28 action_runner
.ExecuteJavaScript(
29 'createAndRead(' + str(size_bytes
) + ');')
30 action_runner
.WaitForJavaScriptCondition(
31 'doneReading === true || errors', 60)
33 errors
= action_runner
.EvaluateJavaScript('errors')
35 raise page_test
.Failure('Errors on page: ' + ', '.join(self
.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',
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;')
50 for size_bytes
in self
._blob
_sizes
:
51 with action_runner
.CreateInteraction('Action_CreateBlob',
53 action_runner
.ExecuteJavaScript('createBlob(' + str(size_bytes
) + ');')
56 for _
in range(0, NUM_BLOB_MASS_CREATE_READS
):
57 with action_runner
.CreateInteraction('Action_ReadBlobs',
59 action_runner
.ExecuteJavaScript('readBlobsSerially();')
60 action_runner
.WaitForJavaScriptCondition(
61 'doneReading === true || errors', 60)
63 errors
= action_runner
.EvaluateJavaScript('errors')
65 raise page_test
.Failure('Errors on page: ' + ', '.join(self
.errors
))
68 class BlobWorkshopPageSet(page_set_module
.PageSet
):
69 """The BlobWorkshop page set."""
72 super(BlobWorkshopPageSet
, self
).__init
__()
74 BlobMassCreate('2Bx200', [2] * 200, self
))
76 BlobMassCreate('1KBx200', [1024] * 200, self
))
78 BlobMassCreate('150KBx200', [150 * 1024] * 200, self
))
80 BlobMassCreate('1MBx200', [1024 * 1024] * 200, self
))
82 BlobMassCreate('10MBx30', [10 * 1024 * 1024] * 30, self
))
84 BlobMassCreate('100MBx5', [100 * 1024 * 1024] * 5, self
))
86 self
.AddUserStory(BlobCreateThenRead('2Bx200', [2] * 200, self
))
87 self
.AddUserStory(BlobCreateThenRead('1KBx200', [1024] * 200, self
))
89 BlobCreateThenRead('150KBx200', [150 * 1024 - 1] * 200, self
))
90 self
.AddUserStory(BlobCreateThenRead('1MBx200', [1024 * 1024] * 200, self
))
92 BlobCreateThenRead('10MBx30', [10 * 1024 * 1024] * 30, self
))
94 BlobCreateThenRead('100MBx5', [100 * 1024 * 1024] * 5, self
))