OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 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 */ |
| 7 |
| 8 #include "Benchmark.h" |
| 9 #include "SkOpts.h" |
| 10 #include "SkRandom.h" |
| 11 |
| 12 struct FloatToHalfBench : public Benchmark { |
| 13 const char* onGetName() override { return "float_to_half"; } |
| 14 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi
ng_Backend; } |
| 15 |
| 16 void onDraw(int loops, SkCanvas* canvas) override { |
| 17 SkRandom rand; |
| 18 float fs[1023]; |
| 19 for (float& f : fs) { |
| 20 f = rand.nextF(); |
| 21 } |
| 22 |
| 23 uint16_t hs[1023]; |
| 24 while (loops --> 0) { |
| 25 SkOpts::float_to_half(hs, fs, 1023); |
| 26 } |
| 27 } |
| 28 }; |
| 29 DEF_BENCH(return new FloatToHalfBench;) |
| 30 |
| 31 struct HalfToFloatBench : public Benchmark { |
| 32 const char* onGetName() override { return "half_to_float"; } |
| 33 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi
ng_Backend; } |
| 34 |
| 35 void onDraw(int loops, SkCanvas* canvas) override { |
| 36 SkRandom rand; |
| 37 uint16_t hs[1023]; |
| 38 for (uint16_t& h : hs) { |
| 39 h = rand.nextU16(); |
| 40 } |
| 41 |
| 42 float fs[1023]; |
| 43 while (loops --> 0) { |
| 44 SkOpts::half_to_float(fs, hs, 1023); |
| 45 } |
| 46 } |
| 47 }; |
| 48 DEF_BENCH(return new HalfToFloatBench;) |
OLD | NEW |