Home | History | Annotate | Download | only in bench
      1 /*
      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  */
      7 #include "SkBenchmark.h"
      8 #include "SkThread.h"
      9 
     10 class MutexBench : public SkBenchmark {
     11     enum {
     12         N = SkBENCHLOOP(80),
     13         M = SkBENCHLOOP(200)
     14     };
     15 public:
     16     MutexBench(void* param) : INHERITED(param) {
     17 
     18     }
     19 protected:
     20     virtual const char* onGetName() {
     21         return "mutex";
     22     }
     23 
     24     virtual void onDraw(SkCanvas* canvas) {
     25         for (int i = 0; i < N; i++) {
     26             SK_DECLARE_STATIC_MUTEX(mu);
     27             for (int j = 0; j < M; j++) {
     28                 mu.acquire();
     29                 mu.release();
     30             }
     31         }
     32     }
     33 
     34 private:
     35     typedef SkBenchmark INHERITED;
     36 };
     37 
     38 ///////////////////////////////////////////////////////////////////////////////
     39 
     40 static SkBenchmark* Fact(void* p) { return new MutexBench(p); }
     41 
     42 static BenchRegistry gReg01(Fact);
     43 
     44