skia2/bench
digit@google.com 1771cbf43d posix: Avoid static initializers in static/global mutexes
This patch removes static initializers related to static and
global mutexes from the final library's machine code when
building on a pthread-capable system.

We use PTHREAD_MUTEX_INITIALIZER to perform POD-style
initialization. You need a line like the following to declare
a global mutex with it:

    SkBaseMutex gMutex = { PTHREAD_MUTEX_INITIALIZER };

We introduce the SK_DECLARE_STATIC_MUTEX and SK_DECLARE_GLOBAL_MUTEX
macros to be able to declare static/global mutexes in the source tree
uniformly.

SkMutex is now defined as a sub-class of SkBaseMutex, with standard
construction/destruction semantics. This is useful if the mutex
object is a member of another C++ class, or allocated dynamically.

We also modify a few places to refer to SkBaseMutex instead of a
SkMutex, where it makes sense. Generally speaking, client code
should hold and use pointers to SkBaseMutex whenever they can
now.

We defined a new built-time macro named SK_USE_POSIX_THREADS
to indicate that we're using a pthread-based SkThread.h
interface. The macro will also be used in future patches
to implement other helper thread synchronization classes.

Finally, we inline the acquire() and release() functions in the
case of Posix to improve performance a bit.

Running: 'bench -repeat 10 -match mutex' on an Android device or
a 2.4GHz Xeon Linux desktop shows the following improvements:

                      Before     After

        Galaxy Nexus    1.64      1.45
        Nexus S         1.47      1.16
        Xoom            1.86      1.66
        Xeon            0.36      0.31

This removes 5 static mutex initializers from the library
Review URL: https://codereview.appspot.com/5501066

git-svn-id: http://skia.googlecode.com/svn/trunk@3091 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-01-26 21:26:40 +00:00
..
BenchTool/BenchTool.xcodeproj move main.cpp outside of the xcode project 2009-01-07 11:49:19 +00:00
AAClipBench.cpp speedup AAClip::setRegion (n^2 to n) 2011-11-28 19:54:56 +00:00
bench_compare.py Add graphing for multiple runs of bench. 2011-06-17 13:58:14 +00:00
bench_graph_svg.py More little improvements to bench_graph_svg.py 2011-08-08 20:27:04 +00:00
bench_util.py Incremental improvements to bench graph generation 2011-08-08 17:19:23 +00:00
BenchGpuTimer_gl.cpp Virtualize SkGLContext with subclasses SkNativeGLContext and SkMesaGLContext, allow both in gm 2011-10-19 20:43:20 +00:00
BenchGpuTimer_gl.h Virtualize SkGLContext with subclasses SkNativeGLContext and SkMesaGLContext, allow both in gm 2011-10-19 20:43:20 +00:00
benchmain.cpp Towards enabling -Werror in skia on Linux 2012-01-06 19:22:11 +00:00
BenchSysTimer_c.cpp Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
BenchSysTimer_c.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
BenchSysTimer_mach.cpp Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
BenchSysTimer_mach.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
BenchSysTimer_posix.cpp Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
BenchSysTimer_posix.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
BenchSysTimer_windows.cpp Fix wall clock in bench system timer on Windows. 2011-10-19 22:10:21 +00:00
BenchSysTimer_windows.h Fix two warnings in bench timers. 2011-10-03 20:44:39 +00:00
BenchTimer.cpp Adding support to trunk for building Skia using the Android NDK. 2011-11-03 13:08:29 +00:00
BenchTimer.h Virtualize SkGLContext with subclasses SkNativeGLContext and SkMesaGLContext, allow both in gm 2011-10-19 20:43:20 +00:00
BitmapBench.cpp In debug builds, only run each benchmark 1 time (test for assertion-breakage, 2011-10-28 15:34:49 +00:00
BlurBench.cpp Add fractional-radius blurs to blur benchmark. 2011-11-22 15:58:06 +00:00
ChromeBench.cpp In debug builds, only run each benchmark 1 time (test for assertion-breakage, 2011-10-28 15:34:49 +00:00
DecodeBench.cpp In debug builds, only run each benchmark 1 time (test for assertion-breakage, 2011-10-28 15:34:49 +00:00
FontScalerBench.cpp use new PurgeFontCache() api 2011-11-08 20:03:48 +00:00
GradientBench.cpp In debug builds, only run each benchmark 1 time (test for assertion-breakage, 2011-10-28 15:34:49 +00:00
MathBench.cpp rename sk_float_isNaN to sk_float_isnan to match related functions 2011-12-06 20:18:05 +00:00
MatrixBench.cpp Fixes int to scalar warnings. This checkin changes the range of random matrix values in a benchmark but it is believed not to affect the runtime. 2011-11-10 13:50:19 +00:00
MutexBench.cpp posix: Avoid static initializers in static/global mutexes 2012-01-26 21:26:40 +00:00
PathBench.cpp Add a wide stroked line path benchmark to bench. It uses the same stroke width 2012-01-12 19:10:35 +00:00
RectBench.cpp In debug builds, only run each benchmark 1 time (test for assertion-breakage, 2011-10-28 15:34:49 +00:00
RepeatTileBench.cpp In debug builds, only run each benchmark 1 time (test for assertion-breakage, 2011-10-28 15:34:49 +00:00
ScalarBench.cpp In debug builds, only run each benchmark 1 time (test for assertion-breakage, 2011-10-28 15:34:49 +00:00
ShaderMaskBench.cpp add bench for shader+blitMask 2011-11-15 15:29:45 +00:00
SkBenchmark.cpp Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkBenchmark.h In debug builds, only run each benchmark 1 time (test for assertion-breakage, 2011-10-28 15:34:49 +00:00
TextBench.cpp add test for drawPosText, to measure any difference it introduces given that 2011-11-23 15:52:02 +00:00
VertBench.cpp Fix pure virtual call from destructor and turn VertBench back on 2011-10-28 19:50:21 +00:00