tomhudson@google.com | 71dd3e0 | 2011-10-27 13:27:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 7 | #include "Benchmark.h" |
tomhudson@google.com | 71dd3e0 | 2011-10-27 13:27:20 +0000 | [diff] [blame] | 8 | #include "SkCanvas.h" |
| 9 | #include "SkPaint.h" |
| 10 | #include "SkString.h" |
| 11 | |
| 12 | /** |
| 13 | Benchmarks that try to emulate a particular Skia call pattern observed in Chrome. |
| 14 | */ |
| 15 | |
| 16 | /// blitRect() calls emitted by Chrome while scrolling through gmail: count, width, height. |
| 17 | int gmailScrollingRectSpec [431*3] = { |
| 18 | 1, 1254, 1160, |
| 19 | 1, 64, 112, |
| 20 | 1, 1034, 261, |
| 21 | 1, 1166, 1, |
| 22 | 1, 1166, 20, |
| 23 | 1, 1254, 40, |
| 24 | 1, 140, 20, |
| 25 | 1, 22, 30, |
| 26 | 1, 22, 39, |
| 27 | 1, 294, 29, |
| 28 | 1, 336, 25, |
| 29 | 1, 336, 5, |
| 30 | 1, 37, 3, |
| 31 | 1, 37, 4, |
| 32 | 1, 37, 5, |
| 33 | 1, 41, 29, |
| 34 | 1, 57, 15, |
| 35 | 1, 72, 5, |
| 36 | 1, 72, 8, |
| 37 | 1, 76, 29, |
| 38 | 1, 981, 88, |
| 39 | 1, 990, 2, |
| 40 | 1, 990, 6, |
| 41 | 2, 220, 88, |
| 42 | 2, 294, 1, |
| 43 | 2, 37, 6, |
| 44 | 2, 391, 55, |
| 45 | 2, 57, 11, |
| 46 | 2, 57, 14, |
| 47 | 2, 57, 7, |
| 48 | 2, 981, 30, |
| 49 | 2, 990, 15, |
| 50 | 2, 990, 19, |
| 51 | 3, 114, 16, |
| 52 | 3, 1166, 39, |
| 53 | 3, 1254, 154, |
| 54 | 3, 12, 12, |
| 55 | 3, 162, 7, |
| 56 | 3, 164, 479, |
| 57 | 3, 167, 449, |
| 58 | 3, 16, 24, |
| 59 | 3, 204, 497, |
| 60 | 3, 205, 434, |
| 61 | 3, 220, 1127, |
| 62 | 3, 220, 1132, |
| 63 | 3, 220, 931, |
| 64 | 3, 220, 933, |
| 65 | 3, 220, 934, |
| 66 | 3, 297, 8, |
| 67 | 3, 72, 25, |
| 68 | 3, 87, 30, |
| 69 | 3, 981, 1, |
| 70 | 3, 981, 126, |
| 71 | 3, 990, 27, |
| 72 | 3, 990, 36, |
| 73 | 3, 991, 29, |
| 74 | 4, 1254, 306, |
| 75 | 4, 1254, 36, |
| 76 | 4, 1, 1, |
| 77 | 4, 1, 14, |
| 78 | 4, 1, 19, |
| 79 | 4, 1, 7, |
| 80 | 4, 21, 21, |
| 81 | 4, 220, 30, |
| 82 | 4, 46, 949, |
| 83 | 4, 509, 30, |
| 84 | 4, 57, 2, |
| 85 | 4, 57, 6, |
| 86 | 4, 990, 11, |
| 87 | 5, 13, 8, |
| 88 | 5, 198, 24, |
| 89 | 5, 24, 24, |
| 90 | 5, 25, 24, |
| 91 | 5, 2, 24, |
| 92 | 5, 37, 33, |
| 93 | 5, 57, 4, |
| 94 | 5, 599, 24, |
| 95 | 5, 90, 24, |
| 96 | 5, 981, 19, |
| 97 | 5, 990, 23, |
| 98 | 5, 990, 8, |
| 99 | 6, 101, 29, |
| 100 | 6, 117, 29, |
| 101 | 6, 1254, 88, |
| 102 | 6, 139, 29, |
| 103 | 6, 13, 12, |
| 104 | 6, 15, 15, |
| 105 | 6, 164, 25, |
| 106 | 6, 16, 16, |
| 107 | 6, 198, 7, |
| 108 | 6, 1, 12, |
| 109 | 6, 1, 15, |
| 110 | 6, 1, 27, |
| 111 | 6, 220, 936, |
| 112 | 6, 24, 7, |
| 113 | 6, 25, 7, |
| 114 | 6, 2, 7, |
| 115 | 6, 326, 29, |
| 116 | 6, 336, 29, |
| 117 | 6, 599, 7, |
| 118 | 6, 86, 29, |
| 119 | 6, 90, 7, |
| 120 | 6, 96, 29, |
| 121 | 6, 991, 31, |
| 122 | 7, 198, 12, |
| 123 | 7, 198, 20, |
| 124 | 7, 198, 33, |
| 125 | 7, 198, 35, |
| 126 | 7, 24, 12, |
| 127 | 7, 24, 20, |
| 128 | 7, 24, 33, |
| 129 | 7, 24, 35, |
| 130 | 7, 25, 12, |
| 131 | 7, 25, 20, |
| 132 | 7, 25, 33, |
| 133 | 7, 25, 35, |
| 134 | 7, 2, 12, |
| 135 | 7, 2, 20, |
| 136 | 7, 2, 33, |
| 137 | 7, 2, 35, |
| 138 | 7, 304, 1, |
| 139 | 7, 38, 29, |
| 140 | 7, 51, 29, |
| 141 | 7, 599, 12, |
| 142 | 7, 599, 20, |
| 143 | 7, 599, 33, |
| 144 | 7, 599, 35, |
| 145 | 7, 90, 12, |
| 146 | 7, 90, 20, |
| 147 | 7, 90, 33, |
| 148 | 7, 90, 35, |
| 149 | 8, 13, 5, |
| 150 | 8, 198, 13, |
| 151 | 8, 198, 23, |
| 152 | 8, 220, 1, |
| 153 | 8, 24, 13, |
| 154 | 8, 24, 23, |
| 155 | 8, 25, 13, |
| 156 | 8, 25, 23, |
| 157 | 8, 2, 13, |
| 158 | 8, 2, 23, |
| 159 | 8, 329, 28, |
| 160 | 8, 57, 10, |
| 161 | 8, 599, 13, |
| 162 | 8, 599, 23, |
| 163 | 8, 90, 13, |
| 164 | 8, 90, 23, |
| 165 | 9, 198, 17, |
| 166 | 9, 198, 19, |
| 167 | 9, 198, 37, |
| 168 | 9, 198, 5, |
| 169 | 9, 198, 8, |
| 170 | 9, 24, 17, |
| 171 | 9, 24, 19, |
| 172 | 9, 24, 37, |
| 173 | 9, 24, 5, |
| 174 | 9, 24, 8, |
| 175 | 9, 25, 17, |
| 176 | 9, 25, 19, |
| 177 | 9, 25, 37, |
| 178 | 9, 25, 5, |
| 179 | 9, 25, 8, |
| 180 | 9, 2, 17, |
| 181 | 9, 2, 19, |
| 182 | 9, 2, 37, |
| 183 | 9, 2, 5, |
| 184 | 9, 2, 8, |
| 185 | 9, 599, 17, |
| 186 | 9, 599, 19, |
| 187 | 9, 599, 37, |
| 188 | 9, 599, 5, |
| 189 | 9, 599, 8, |
| 190 | 9, 72, 29, |
| 191 | 9, 90, 17, |
| 192 | 9, 90, 19, |
| 193 | 9, 90, 37, |
| 194 | 9, 90, 5, |
| 195 | 9, 90, 8, |
| 196 | 10, 13, 11, |
| 197 | 10, 13, 9, |
| 198 | 10, 198, 26, |
| 199 | 10, 198, 28, |
| 200 | 10, 1, 23, |
| 201 | 10, 1, 4, |
| 202 | 10, 1, 6, |
| 203 | 10, 24, 26, |
| 204 | 10, 24, 28, |
| 205 | 10, 25, 26, |
| 206 | 10, 25, 28, |
| 207 | 10, 26, 24, |
| 208 | 10, 2, 26, |
| 209 | 10, 2, 28, |
| 210 | 10, 599, 26, |
| 211 | 10, 599, 28, |
| 212 | 10, 90, 26, |
| 213 | 10, 90, 28, |
| 214 | 11, 198, 27, |
| 215 | 11, 24, 27, |
| 216 | 11, 25, 27, |
| 217 | 11, 2, 27, |
| 218 | 11, 599, 27, |
| 219 | 11, 90, 27, |
| 220 | 12, 198, 14, |
| 221 | 12, 198, 21, |
| 222 | 12, 198, 3, |
| 223 | 12, 1, 11, |
| 224 | 12, 1, 2, |
| 225 | 12, 1, 8, |
| 226 | 12, 24, 14, |
| 227 | 12, 24, 21, |
| 228 | 12, 24, 3, |
| 229 | 12, 25, 14, |
| 230 | 12, 25, 21, |
| 231 | 12, 25, 3, |
| 232 | 12, 26, 7, |
| 233 | 12, 2, 14, |
| 234 | 12, 2, 21, |
| 235 | 12, 2, 3, |
| 236 | 12, 329, 14, |
| 237 | 12, 38, 2, |
| 238 | 12, 599, 14, |
| 239 | 12, 599, 21, |
| 240 | 12, 599, 3, |
| 241 | 12, 90, 14, |
| 242 | 12, 90, 21, |
| 243 | 12, 90, 3, |
| 244 | 13, 198, 11, |
| 245 | 13, 198, 15, |
| 246 | 13, 198, 31, |
| 247 | 13, 24, 11, |
| 248 | 13, 24, 15, |
| 249 | 13, 24, 31, |
| 250 | 13, 25, 11, |
| 251 | 13, 25, 15, |
| 252 | 13, 25, 31, |
| 253 | 13, 2, 11, |
| 254 | 13, 2, 15, |
| 255 | 13, 2, 31, |
| 256 | 13, 57, 13, |
| 257 | 13, 599, 11, |
| 258 | 13, 599, 15, |
| 259 | 13, 599, 31, |
| 260 | 13, 71, 29, |
| 261 | 13, 90, 11, |
| 262 | 13, 90, 15, |
| 263 | 13, 90, 31, |
| 264 | 14, 13, 2, |
| 265 | 14, 198, 10, |
| 266 | 14, 24, 10, |
| 267 | 14, 25, 10, |
| 268 | 14, 26, 12, |
| 269 | 14, 26, 20, |
| 270 | 14, 26, 33, |
| 271 | 14, 26, 35, |
| 272 | 14, 2, 10, |
| 273 | 14, 336, 1, |
| 274 | 14, 45, 29, |
| 275 | 14, 599, 10, |
| 276 | 14, 63, 29, |
| 277 | 14, 90, 10, |
| 278 | 15, 13, 3, |
| 279 | 15, 198, 2, |
| 280 | 15, 198, 29, |
| 281 | 15, 198, 34, |
| 282 | 15, 24, 2, |
| 283 | 15, 24, 29, |
| 284 | 15, 24, 34, |
| 285 | 15, 25, 2, |
| 286 | 15, 25, 29, |
| 287 | 15, 25, 34, |
| 288 | 15, 2, 2, |
| 289 | 15, 2, 29, |
| 290 | 15, 2, 34, |
| 291 | 15, 599, 2, |
| 292 | 15, 599, 29, |
| 293 | 15, 599, 34, |
| 294 | 15, 90, 2, |
| 295 | 15, 90, 29, |
| 296 | 15, 90, 34, |
| 297 | 16, 13, 4, |
| 298 | 16, 13, 6, |
| 299 | 16, 198, 16, |
| 300 | 16, 198, 9, |
| 301 | 16, 1, 10, |
| 302 | 16, 24, 16, |
| 303 | 16, 24, 9, |
| 304 | 16, 25, 16, |
| 305 | 16, 25, 9, |
| 306 | 16, 26, 13, |
| 307 | 16, 26, 23, |
| 308 | 16, 2, 16, |
| 309 | 16, 2, 9, |
| 310 | 16, 599, 16, |
| 311 | 16, 599, 9, |
| 312 | 16, 90, 16, |
| 313 | 16, 90, 9, |
| 314 | 17, 13, 7, |
| 315 | 17, 198, 18, |
| 316 | 17, 24, 18, |
| 317 | 17, 25, 18, |
| 318 | 17, 2, 18, |
| 319 | 17, 599, 18, |
| 320 | 17, 90, 18, |
| 321 | 18, 198, 22, |
| 322 | 18, 198, 32, |
| 323 | 18, 198, 36, |
| 324 | 18, 198, 4, |
| 325 | 18, 24, 22, |
| 326 | 18, 24, 32, |
| 327 | 18, 24, 36, |
| 328 | 18, 24, 4, |
| 329 | 18, 25, 22, |
| 330 | 18, 25, 32, |
| 331 | 18, 25, 36, |
| 332 | 18, 25, 4, |
| 333 | 18, 26, 17, |
| 334 | 18, 26, 19, |
| 335 | 18, 26, 37, |
| 336 | 18, 26, 5, |
| 337 | 18, 26, 8, |
| 338 | 18, 2, 22, |
| 339 | 18, 2, 32, |
| 340 | 18, 2, 36, |
| 341 | 18, 2, 4, |
| 342 | 18, 599, 22, |
| 343 | 18, 599, 32, |
| 344 | 18, 599, 36, |
| 345 | 18, 599, 4, |
| 346 | 18, 90, 22, |
| 347 | 18, 90, 32, |
| 348 | 18, 90, 36, |
| 349 | 18, 90, 4, |
| 350 | 19, 13, 10, |
| 351 | 20, 1254, 30, |
| 352 | 20, 16, 1007, |
| 353 | 20, 26, 26, |
| 354 | 20, 26, 28, |
| 355 | 21, 198, 6, |
| 356 | 21, 24, 6, |
| 357 | 21, 25, 6, |
| 358 | 21, 2, 6, |
| 359 | 21, 599, 6, |
| 360 | 21, 90, 6, |
| 361 | 22, 198, 38, |
| 362 | 22, 22, 40, |
| 363 | 22, 24, 38, |
| 364 | 22, 25, 38, |
| 365 | 22, 26, 27, |
| 366 | 22, 2, 38, |
| 367 | 22, 599, 38, |
| 368 | 22, 90, 38, |
| 369 | 23, 1254, 1160, |
| 370 | 24, 220, 930, |
| 371 | 24, 26, 14, |
| 372 | 24, 26, 21, |
| 373 | 24, 26, 3, |
| 374 | 26, 11, 11, |
| 375 | 26, 1, 13, |
| 376 | 26, 26, 11, |
| 377 | 26, 26, 15, |
| 378 | 26, 26, 31, |
| 379 | 28, 26, 10, |
| 380 | 30, 176, 60, |
| 381 | 30, 26, 2, |
| 382 | 30, 26, 29, |
| 383 | 30, 26, 34, |
| 384 | 32, 26, 16, |
| 385 | 32, 26, 9, |
| 386 | 34, 26, 18, |
| 387 | 36, 26, 22, |
| 388 | 36, 26, 32, |
| 389 | 36, 26, 36, |
| 390 | 36, 26, 4, |
| 391 | 36, 37, 26, |
| 392 | 42, 26, 6, |
| 393 | 43, 115, 29, |
| 394 | 44, 198, 25, |
| 395 | 44, 24, 25, |
| 396 | 44, 25, 25, |
| 397 | 44, 26, 38, |
| 398 | 44, 2, 25, |
| 399 | 44, 599, 25, |
| 400 | 44, 90, 25, |
| 401 | 46, 22, 1, |
| 402 | 47, 198, 30, |
| 403 | 47, 25, 30, |
| 404 | 47, 2, 30, |
| 405 | 47, 599, 30, |
| 406 | 47, 90, 30, |
| 407 | 48, 24, 30, |
| 408 | 52, 176, 30, |
| 409 | 58, 140, 24, |
| 410 | 58, 4, 30, |
| 411 | 63, 990, 29, |
| 412 | 64, 1254, 1, |
| 413 | 88, 26, 25, |
| 414 | 92, 198, 39, |
| 415 | 92, 25, 39, |
| 416 | 92, 2, 39, |
| 417 | 92, 599, 39, |
| 418 | 92, 90, 39, |
| 419 | 93, 24, 39, |
| 420 | 94, 26, 30, |
| 421 | 108, 1254, 1051, |
| 422 | 117, 140, 1, |
| 423 | 119, 160, 1, |
| 424 | 126, 1, 29, |
| 425 | 132, 135, 16, |
| 426 | 147, 72, 16, |
| 427 | 184, 26, 39, |
| 428 | 238, 990, 1, |
| 429 | 376, 11, 1007, |
| 430 | 380, 11, 487, |
| 431 | 1389, 1034, 1007, |
| 432 | 1870, 57, 16, |
| 433 | 4034, 1, 16, |
| 434 | 8521, 198, 40, |
| 435 | 8521, 25, 40, |
| 436 | 8521, 2, 40, |
| 437 | 8521, 599, 40, |
| 438 | 8521, 90, 40, |
| 439 | 8543, 24, 40, |
| 440 | 8883, 13, 13, |
| 441 | 17042, 26, 40, |
| 442 | 17664, 198, 1, |
| 443 | 17664, 25, 1, |
| 444 | 17664, 2, 1, |
| 445 | 17664, 599, 1, |
| 446 | 17664, 90, 1, |
| 447 | 17710, 24, 1, |
| 448 | 35328, 26, 1, |
| 449 | }; |
| 450 | |
| 451 | /// Emulates the mix of rects blitted by gmail during scrolling |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 452 | class ScrollGmailBench : public Benchmark { |
tomhudson@google.com | 71dd3e0 | 2011-10-27 13:27:20 +0000 | [diff] [blame] | 453 | enum { |
| 454 | W = 1254, |
| 455 | H = 1160, |
| 456 | N = 431 |
| 457 | }; |
| 458 | public: |
mtklein@google.com | 410e6e8 | 2013-09-13 19:52:27 +0000 | [diff] [blame] | 459 | ScrollGmailBench() { } |
tomhudson@google.com | 71dd3e0 | 2011-10-27 13:27:20 +0000 | [diff] [blame] | 460 | |
| 461 | protected: |
| 462 | |
| 463 | virtual const char* onGetName() { return "chrome_scrollGmail"; } |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 464 | virtual void onDraw(int loops, SkCanvas* canvas) { |
tomhudson@google.com | 71dd3e0 | 2011-10-27 13:27:20 +0000 | [diff] [blame] | 465 | SkDEBUGCODE(this->validateBounds(canvas)); |
| 466 | SkPaint paint; |
| 467 | this->setupPaint(&paint); |
| 468 | for (int i = 0; i < N; i++) { |
| 469 | SkRect current; |
| 470 | setRectangle(current, i); |
commit-bot@chromium.org | 3361471 | 2013-12-03 18:17:16 +0000 | [diff] [blame] | 471 | for (int j = 0; j < loops * gmailScrollingRectSpec[i*3]; j++) { |
tomhudson@google.com | 71dd3e0 | 2011-10-27 13:27:20 +0000 | [diff] [blame] | 472 | canvas->drawRect(current, paint); |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | virtual SkIPoint onGetSize() { return SkIPoint::Make(W, H); } |
| 477 | |
| 478 | void setRectangle(SkRect& current, int i) { |
| 479 | current.set(0, 0, |
| 480 | SkIntToScalar(gmailScrollingRectSpec[i*3+1]), SkIntToScalar(gmailScrollingRectSpec[i*3+2])); |
| 481 | } |
| 482 | void validateBounds(SkCanvas* canvas) { |
Mike Reed | 918e144 | 2017-01-23 11:39:45 -0500 | [diff] [blame] | 483 | #ifdef SK_DEBUG |
| 484 | SkIRect bounds = canvas->getDeviceClipBounds(); |
tomhudson@google.com | 71dd3e0 | 2011-10-27 13:27:20 +0000 | [diff] [blame] | 485 | SkASSERT(bounds.right()-bounds.left() >= W); |
| 486 | SkASSERT(bounds.bottom()-bounds.top() >= H); |
Mike Reed | 918e144 | 2017-01-23 11:39:45 -0500 | [diff] [blame] | 487 | #endif |
tomhudson@google.com | 71dd3e0 | 2011-10-27 13:27:20 +0000 | [diff] [blame] | 488 | } |
| 489 | |
| 490 | |
| 491 | private: |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 492 | typedef Benchmark INHERITED; |
tomhudson@google.com | 71dd3e0 | 2011-10-27 13:27:20 +0000 | [diff] [blame] | 493 | }; |
| 494 | |
tomhudson@google.com | af2313e | 2012-03-14 18:33:54 +0000 | [diff] [blame] | 495 | // Disabled this benchmark: it takes 15x longer than any other benchmark |
| 496 | // and is probably not giving us important information. |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 497 | // DEF_BENCH(return new ScrollGmailBench); |