OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This small program is used to measure the performance of the various | 5 // This small program is used to measure the performance of the various |
6 // resize algorithms offered by the ImageOperations::Resize function. | 6 // resize algorithms offered by the ImageOperations::Resize function. |
7 // It will generate an empty source bitmap, and rescale it to specified | 7 // It will generate an empty source bitmap, and rescale it to specified |
8 // dimensions. It will repeat this operation multiple time to get more accurate | 8 // dimensions. It will repeat this operation multiple time to get more accurate |
9 // average throughput. Because it uses elapsed time to do its math, it is only | 9 // average throughput. Because it uses elapsed time to do its math, it is only |
10 // accurate on an idle system (but that approach was deemed more accurate | 10 // accurate on an idle system (but that approach was deemed more accurate |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 return height_; | 112 return height_; |
113 } | 113 } |
114 | 114 |
115 bool IsValid() const { | 115 bool IsValid() const { |
116 return (width_ > 0 && height_ > 0); | 116 return (width_ > 0 && height_ > 0); |
117 } | 117 } |
118 | 118 |
119 // On failure, will set its state in such a way that IsValid will return | 119 // On failure, will set its state in such a way that IsValid will return |
120 // false. | 120 // false. |
121 void FromString(const std::string& arg) { | 121 void FromString(const std::string& arg) { |
122 std::vector<std::string> strings; | 122 std::vector<base::StringPiece> strings = base::SplitStringPiece( |
123 base::SplitString(std::string(arg), 'x', &strings); | 123 arg, "x", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
124 if (strings.size() != 2 || | 124 if (strings.size() != 2 || |
125 base::StringToInt(strings[0], &width_) == false || | 125 base::StringToInt(strings[0], &width_) == false || |
126 base::StringToInt(strings[1], &height_) == false) { | 126 base::StringToInt(strings[1], &height_) == false) { |
127 width_ = -1; // force the dimension object to be invalid. | 127 width_ = -1; // force the dimension object to be invalid. |
128 } | 128 } |
129 } | 129 } |
130 private: | 130 private: |
131 int width_; | 131 int width_; |
132 int height_; | 132 int height_; |
133 }; | 133 }; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 return 1; | 281 return 1; |
282 } | 282 } |
283 | 283 |
284 if (!bench.Run()) { | 284 if (!bench.Run()) { |
285 printf("Failed to run benchmark\n"); | 285 printf("Failed to run benchmark\n"); |
286 return 1; | 286 return 1; |
287 } | 287 } |
288 | 288 |
289 return 0; | 289 return 0; |
290 } | 290 } |
OLD | NEW |