2011-11-14 17:30:08 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2014-06-19 19:32:29 +00:00
|
|
|
#include "Benchmark.h"
|
2011-11-14 17:30:08 +00:00
|
|
|
#include "SkThread.h"
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
class MutexBench : public Benchmark {
|
2011-11-14 17:30:08 +00:00
|
|
|
public:
|
2015-03-26 01:17:31 +00:00
|
|
|
bool isSuitableFor(Backend backend) override {
|
2013-11-21 06:21:58 +00:00
|
|
|
return backend == kNonRendering_Backend;
|
2011-11-14 17:30:08 +00:00
|
|
|
}
|
2013-11-21 06:21:58 +00:00
|
|
|
|
2011-11-14 17:30:08 +00:00
|
|
|
protected:
|
|
|
|
virtual const char* onGetName() {
|
|
|
|
return "mutex";
|
|
|
|
}
|
|
|
|
|
2013-12-03 18:17:16 +00:00
|
|
|
virtual void onDraw(const int loops, SkCanvas*) {
|
2014-07-25 18:52:47 +00:00
|
|
|
SkMutex mu;
|
2013-12-03 18:17:16 +00:00
|
|
|
for (int i = 0; i < loops; i++) {
|
2013-09-10 19:23:38 +00:00
|
|
|
mu.acquire();
|
|
|
|
mu.release();
|
2011-11-14 17:30:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-06-19 19:32:29 +00:00
|
|
|
typedef Benchmark INHERITED;
|
2011-11-14 17:30:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-09-13 19:52:27 +00:00
|
|
|
DEF_BENCH( return new MutexBench(); )
|