OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 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 |
| 8 |
| 9 |
| 10 NUM_BLOB_MASS_CREATE_READS = 15 |
| 11 |
| 12 |
| 13 class BlobCreateThenRead(page_module.Page): |
| 14 |
| 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 |
| 21 |
| 22 def RunPageInteractions(self, action_runner): |
| 23 action_runner.ExecuteJavaScript('disableUI = true;') |
| 24 |
| 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) |
| 32 |
| 33 errors = action_runner.EvaluateJavaScript('errors') |
| 34 if errors: |
| 35 raise page_test.Failure('Errors on page: ' + ', '.join(self.errors)) |
| 36 |
| 37 |
| 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 |
| 45 |
| 46 def RunPageInteractions(self, action_runner): |
| 47 action_runner.ExecuteJavaScript('disableUI = true;') |
| 48 |
| 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) + ');') |
| 54 |
| 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) |
| 62 |
| 63 errors = action_runner.EvaluateJavaScript('errors') |
| 64 if errors: |
| 65 raise page_test.Failure('Errors on page: ' + ', '.join(self.errors)) |
| 66 |
| 67 |
| 68 class BlobWorkshopPageSet(page_set_module.PageSet): |
| 69 """The BlobWorkshop page set.""" |
| 70 |
| 71 def __init__(self): |
| 72 super(BlobWorkshopPageSet, self).__init__() |
| 73 self.AddUserStory( |
| 74 BlobMassCreate('2Bx200', [2] * 200, self)) |
| 75 self.AddUserStory( |
| 76 BlobMassCreate('1KBx200', [1024] * 200, self)) |
| 77 self.AddUserStory( |
| 78 BlobMassCreate('150KBx200', [150 * 1024] * 200, self)) |
| 79 self.AddUserStory( |
| 80 BlobMassCreate('1MBx200', [1024 * 1024] * 200, self)) |
| 81 self.AddUserStory( |
| 82 BlobMassCreate('10MBx30', [10 * 1024 * 1024] * 30, self)) |
| 83 self.AddUserStory( |
| 84 BlobMassCreate('100MBx5', [100 * 1024 * 1024] * 5, self)) |
| 85 |
| 86 self.AddUserStory(BlobCreateThenRead('2Bx200', [2] * 200, self)) |
| 87 self.AddUserStory(BlobCreateThenRead('1KBx200', [1024] * 200, self)) |
| 88 self.AddUserStory( |
| 89 BlobCreateThenRead('150KBx200', [150 * 1024 - 1] * 200, self)) |
| 90 self.AddUserStory(BlobCreateThenRead('1MBx200', [1024 * 1024] * 200, self)) |
| 91 self.AddUserStory( |
| 92 BlobCreateThenRead('10MBx30', [10 * 1024 * 1024] * 30, self)) |
| 93 self.AddUserStory( |
| 94 BlobCreateThenRead('100MBx5', [100 * 1024 * 1024] * 5, self)) |
OLD | NEW |