Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(781)

Side by Side Diff: bench/HalfBench.cpp

Issue 1686543003: skeleton for float <-> half optimized procs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: bench Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkOpts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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;)
OLDNEW
« no previous file with comments | « no previous file | src/core/SkOpts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698