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.
|
|
|
|
*/
|
|
|
|
#include "SkBenchmark.h"
|
|
|
|
#include "SkThread.h"
|
|
|
|
|
|
|
|
class MutexBench : public SkBenchmark {
|
|
|
|
public:
|
2013-09-13 19:52:27 +00:00
|
|
|
MutexBench() {
|
2012-09-17 10:49:30 +00:00
|
|
|
fIsRendering = false;
|
2011-11-14 17:30:08 +00:00
|
|
|
}
|
|
|
|
protected:
|
|
|
|
virtual const char* onGetName() {
|
|
|
|
return "mutex";
|
|
|
|
}
|
|
|
|
|
2013-03-05 18:50:01 +00:00
|
|
|
virtual void onDraw(SkCanvas*) {
|
2013-09-10 19:23:38 +00:00
|
|
|
SK_DECLARE_STATIC_MUTEX(mu);
|
|
|
|
for (int i = 0; i < this->getLoops(); i++) {
|
|
|
|
mu.acquire();
|
|
|
|
mu.release();
|
2011-11-14 17:30:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef SkBenchmark INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-09-13 19:52:27 +00:00
|
|
|
DEF_BENCH( return new MutexBench(); )
|