| OLD | NEW |
| 1 // Copyright (c) 2003, Google Inc. | 1 // Copyright (c) 2003, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #ifdef HAVE_SYS_RESOURCE_H | 38 #ifdef HAVE_SYS_RESOURCE_H |
| 39 #include <sys/time.h> // for struct timeval | 39 #include <sys/time.h> // for struct timeval |
| 40 #include <sys/resource.h> // for getrusage | 40 #include <sys/resource.h> // for getrusage |
| 41 #endif | 41 #endif |
| 42 #ifdef _WIN32 | 42 #ifdef _WIN32 |
| 43 #include <windows.h> // for GetTickCount() | 43 #include <windows.h> // for GetTickCount() |
| 44 #endif | 44 #endif |
| 45 #include <vector> | 45 #include <vector> |
| 46 #include "base/logging.h" | 46 #include "base/logging.h" |
| 47 #include "common.h" | 47 #include "common.h" |
| 48 #include <google/malloc_extension.h> | 48 #include <gperftools/malloc_extension.h> |
| 49 | 49 |
| 50 using std::vector; | 50 using std::vector; |
| 51 | 51 |
| 52 int main(int argc, char** argv) { | 52 int main(int argc, char** argv) { |
| 53 // Make kAllocSize one page larger than the maximum small object size. | 53 // Make kAllocSize one page larger than the maximum small object size. |
| 54 static const int kAllocSize = kMaxSize + kPageSize; | 54 static const int kAllocSize = kMaxSize + kPageSize; |
| 55 // Allocate 400MB in total. | 55 // Allocate 400MB in total. |
| 56 static const int kTotalAlloc = 400 << 20; | 56 static const int kTotalAlloc = 400 << 20; |
| 57 static const int kAllocIterations = kTotalAlloc / kAllocSize; | 57 static const int kAllocIterations = kTotalAlloc / kAllocSize; |
| 58 | 58 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 #else | 123 #else |
| 124 # error No way to calculate time on your system | 124 # error No way to calculate time on your system |
| 125 #endif | 125 #endif |
| 126 fprintf(stderr, "getproperty: %6.1f ns/call\n", | 126 fprintf(stderr, "getproperty: %6.1f ns/call\n", |
| 127 (sumsec * 1e9 + sumusec * 1e3) / kIterations); | 127 (sumsec * 1e9 + sumusec * 1e3) / kIterations); |
| 128 } | 128 } |
| 129 | 129 |
| 130 printf("PASS\n"); | 130 printf("PASS\n"); |
| 131 return 0; | 131 return 0; |
| 132 } | 132 } |
| OLD | NEW |