We introduces SkyPat, a C++ performance analysis toolkit on Linux. SkyPat combines unit tests and perf_event to give programmers the power of accomplishing reliability and performance test simultaneously.


SkyPat (Currently v2.9) has a few easy ways to get started. You may find the best fit for you.

Support Platforms

Fedora 20
Mac OS X 10.9.2
Ubuntu 13.10

Getting Started

Download and build SkyPat

You could download SkyPat either from the latest release tar-ball or from our git repository.

Method 1: Download SkyPat from the latest release tar-ball

Download the source code from the latest release tar-ball.

$ wget
$ tar zxvf pat-2.8.0.tar.gz ${PAT_SRC}

Method 2: Download SkyPat from our git repository

Download the source code from our git repository into ${PAT_SRC} directory.

$ git clone ${PAT_SRC}

Build by dancing with Auto-tools

If there are no configure shell script in the directory, use ./ to generate configure script.

$ ./

Use ./configure to configure the package for your system. See INSTALL for more details.

$ ./configure --prefix=${PAT_INSTALL}

Use make to compile the package

$ make

Type make install to install the package into your system.

$ make install

Run Examples

Examples of SkyPat are installed at ${PAT_INSTALL}/share/pat/examples. You can go to any sub-directory and build it. For example:

$ cd ${PAT_INSTALL}/share/pat/examples/assertion
$ make

Then, if SkyPat is successfully installed, you should see:

c++ -I../../../../include -L../../../../lib main.cpp my_case.cpp -lpat -o assertion
  LD_LIBRARY_PATH=../../../../lib ./assertion
  [    pat   ] Running 2 tests from 1 cases.
  [----------] 2 tests from MyCase.
  [ RUN      ] MyCase.fibonacci_test
  [       OK ] 
  [ RUN      ] MyCase.factorial_test
  [       OK ] 
  [==========] 2 tests from 1 cases ran.
  [  PASSED  ] 2 tests.

How To Use

This document explains how to use pat to test your program and evaluate its performance.


SkyPat is a C++ performance analyzing and testing framework on Android and Linux platforms. We refer the concept of Google Test and extend its scope from testing framework into Performance Analysis Framework.

With the help of pat, programmers who wants to analyze their program, only need to write test cases via pat, and pat can analyze programs' correctness and performance.

The following section provides examples to show how to use pat.

Basic concept

The easiest steps to use pat are:

  • Writing test cases including ASSERT, EXPECT, and PERFORM macros.

  • Compiling these cases with your main program and the shared library of pat.

  • Finally, to execute the binary file and you can get its correctness and performance.

Like Google Test, pat provides several macro to integrate your test cases and your main program. The next section introduces to each macro and explains how to use these macros to write your test-cases.


There are three kinds of macros in pat, ASSERT, EXPECT, and PERFORM. ASSERT and EXPECT are assertions for condition testing and PERFORM wraps a block of code for performance testing. The difference between ASSERT and EXPECT is whether it is fatal or not.

ASSERT is assertion for fatal condition testing. That is to say, if the condition of ASSERT_* fails, the test fails and stops immediately.

EXPECT is non-fatal assertion. When the condition of EXPECT_* fails, it displays on screen to indicate that is a non-fatal failure. The whole test keeps running and isn't considered as a failure.

PERFORM evaluates performance rather than correctness. With the help of PERFORM, you could measure the performance of code within a test.

The following sections give you examples to use these macros in your test program and explains the meanings of the output results.


All examples listed here are also in pat's source code, ${PAT_SRC}/examples.

Include PAT

Let's start from the most useful macro: ASSERT. All macros and definitions used in pat are located in the file

For example, in assertion/main.cpp, it includes:

#include "pat/pat.h"

Declare A Test Function via PAT_F

PAT_F macro declare a test. It has two parameters: test case's name and test function's name. In pat, test logic is grouped into test cases. Every test case has a bunch of test functions. Here is an example to declare a test function.

PAT_F(AircraftCase, take_off_test)
/* My Wonderful Test Code */
PAT_F(AircraftCase, landing_test)
/* My Wonderful Test Code */

This example defines a test case AircraftCase who has two test functions take_off_test and landing_test. This is how does the "pat" organize the test codes. You should put logically related tests into the same test case.


If you have any problems or questions on download, release, etc, please don’t hesitate to reach us.

  • Issue Report

    If you ever face any problems while using SkyPat, please share the bug with us. We will fix it as soon as possible.

  • Feature Request

    Looking for a even more powerful performance test framework? Please share your need with us and we will try to be the one for you.

  • Release Information

    You may find all the release details here.

  • Mailing List

    We provide release notification service to keep you updated all the time. If you are keen to the latest version, please subscribe here.

  • Download from Github

    Not satisfied with .zip or .tar.gz? You can find more ways to download here.


We introduces SkyPat, a C++ performance analysis toolkit on Linux. SkyPat combines unit tests and perf_event to give programmers the power of accomplishing reliability and performance test simultaneously.

Unlike traditional tools that manipulate entire program as a black-box, SkyPat works on a region of code like a white-box. It is used as a normal unit test library. It provides macros and assertions, into which perf_events are embedded, to ensure correctness and to evaluate performance of a region of code. With perf_events, SkyPat can evaluate running time precisely without interference to scheduler. Moreover, perf_event also gives SkyPat accurate cycle counts that are useful for tools that are sensitive to variance of timing, such as compilers.

We develop SkyPat under the new BSD license.

Who Is Using SkyPat?

Bold, BSD Optimizing Linker


Ping-Hao Chang, et al. "SkyPat: C++ Performance Analysis and Testing Framework." Linux Symposium