]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* Copyright (c) 2011 Facebook | |
4 | * | |
5 | * Permission to use, copy, modify, and distribute this software for any | |
6 | * purpose with or without fee is hereby granted, provided that the above | |
7 | * copyright notice and this permission notice appear in all copies. | |
8 | * | |
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIM ALL WARRANTIES | |
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHORS BE LIABLE FOR | |
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
16 | */ | |
17 | ||
18 | #include "include/buffer.h" | |
19 | ||
20 | using namespace ceph; | |
21 | ||
22 | namespace PerfHelper { | |
23 | ||
24 | /// Flush the CPU data cache by reading and writing 100MB of new data. | |
25 | void flush_cache() | |
26 | { | |
27 | int hundredMegs = 100 * 1024 * 1024; | |
28 | volatile char* block = new char[hundredMegs]; | |
29 | for (int i = 0; i < hundredMegs; i++) | |
30 | block[i] = 1; | |
31 | delete[] block; | |
32 | } | |
33 | ||
34 | /// Used in functionCall(). | |
35 | uint64_t plus_one(uint64_t x) | |
36 | { | |
37 | return x + 1; | |
38 | } | |
39 | ||
40 | /// Used in throwIntNL. | |
41 | void throw_int() | |
42 | { | |
43 | throw 0; | |
44 | } | |
45 | ||
46 | /// Used in throwExceptionNL. | |
47 | void throw_end_of_buffer() | |
48 | { | |
49 | throw buffer::end_of_buffer(); | |
50 | } | |
51 | } |