]>
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" | |
f67539c2 | 19 | #include "common/error_code.h" |
7c673cae FG |
20 | |
21 | using namespace ceph; | |
22 | ||
23 | namespace PerfHelper { | |
24 | ||
25 | /// Flush the CPU data cache by reading and writing 100MB of new data. | |
26 | void flush_cache() | |
27 | { | |
28 | int hundredMegs = 100 * 1024 * 1024; | |
29 | volatile char* block = new char[hundredMegs]; | |
30 | for (int i = 0; i < hundredMegs; i++) | |
31 | block[i] = 1; | |
32 | delete[] block; | |
33 | } | |
34 | ||
35 | /// Used in functionCall(). | |
36 | uint64_t plus_one(uint64_t x) | |
37 | { | |
38 | return x + 1; | |
39 | } | |
40 | ||
41 | /// Used in throwIntNL. | |
42 | void throw_int() | |
43 | { | |
44 | throw 0; | |
45 | } | |
46 | ||
47 | /// Used in throwExceptionNL. | |
48 | void throw_end_of_buffer() | |
49 | { | |
50 | throw buffer::end_of_buffer(); | |
51 | } | |
52 | } |