blob: 2565d3860e8f5e77bc4486c490acc1a0735b5faa [file] [log] [blame]
tomhudson@google.com410e9dc2011-11-14 17:30:08 +00001/*
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 */
tfarinaf168b862014-06-19 12:32:29 -07007#include "Benchmark.h"
mtklein1b249332015-07-07 12:21:21 -07008#include "SkMutex.h"
tomhudson@google.com410e9dc2011-11-14 17:30:08 +00009
tfarinaf168b862014-06-19 12:32:29 -070010class MutexBench : public Benchmark {
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000011public:
mtklein36352bf2015-03-25 18:17:31 -070012 bool isSuitableFor(Backend backend) override {
commit-bot@chromium.org644629c2013-11-21 06:21:58 +000013 return backend == kNonRendering_Backend;
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000014 }
commit-bot@chromium.org644629c2013-11-21 06:21:58 +000015
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000016protected:
mtkleinf0599002015-07-13 06:18:39 -070017 const char* onGetName() override {
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000018 return "mutex";
19 }
20
mtkleinf0599002015-07-13 06:18:39 -070021 void onDraw(const int loops, SkCanvas*) override {
bungemand6aeb6d2014-07-25 11:52:47 -070022 SkMutex mu;
commit-bot@chromium.org33614712013-12-03 18:17:16 +000023 for (int i = 0; i < loops; i++) {
mtklein@google.comc2897432013-09-10 19:23:38 +000024 mu.acquire();
25 mu.release();
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000026 }
27 }
28
29private:
tfarinaf168b862014-06-19 12:32:29 -070030 typedef Benchmark INHERITED;
tomhudson@google.com410e9dc2011-11-14 17:30:08 +000031};
32
33///////////////////////////////////////////////////////////////////////////////
34
mtklein@google.com410e6e82013-09-13 19:52:27 +000035DEF_BENCH( return new MutexBench(); )