Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: third_party/tcmalloc/chromium/src/tests/profiler_unittest.cc

Issue 7430007: Merge tcmalloc r111 (perftools v. 1.8) with the chromium/ branch. Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2005, Google Inc. 1 // Copyright (c) 2005, 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #ifndef NO_THREADS 54 #ifndef NO_THREADS
55 ProfilerRegisterThread(); 55 ProfilerRegisterThread();
56 56
57 int i, m; 57 int i, m;
58 char b[128]; 58 char b[128];
59 MutexLock ml(&mutex); 59 MutexLock ml(&mutex);
60 for (m = 0; m < 1000000; ++m) { // run millions of times 60 for (m = 0; m < 1000000; ++m) { // run millions of times
61 for (i = 0; i < g_iters; ++i ) { 61 for (i = 0; i < g_iters; ++i ) {
62 result ^= i; 62 result ^= i;
63 } 63 }
64 snprintf(b, sizeof(b), "%d", result); // get some libc action 64 snprintf(b, sizeof(b), "other: %d", result); // get some libc action
65 } 65 }
66 #endif 66 #endif
67 } 67 }
68 68
69 static void test_main_thread() { 69 static void test_main_thread() {
70 int i, m; 70 int i, m;
71 char b[128]; 71 char b[128];
72 MutexLock ml(&mutex); 72 MutexLock ml(&mutex);
73 for (m = 0; m < 1000000; ++m) { // run millions of times 73 for (m = 0; m < 1000000; ++m) { // run millions of times
74 for (i = 0; i < g_iters; ++i ) { 74 for (i = 0; i < g_iters; ++i ) {
75 result ^= i; 75 result ^= i;
76 } 76 }
77 snprintf(b, sizeof(b), "%d", result); // get some libc action 77 snprintf(b, sizeof(b), "same: %d", result); // get some libc action
78 } 78 }
79 } 79 }
80 80
81 int main(int argc, char** argv) { 81 int main(int argc, char** argv) {
82 if ( argc <= 1 ) { 82 if ( argc <= 1 ) {
83 fprintf(stderr, "USAGE: %s <iters> [num_threads] [filename]\n", argv[0]); 83 fprintf(stderr, "USAGE: %s <iters> [num_threads] [filename]\n", argv[0]);
84 fprintf(stderr, " iters: How many million times to run the XOR test.\n"); 84 fprintf(stderr, " iters: How many million times to run the XOR test.\n");
85 fprintf(stderr, " num_threads: how many concurrent threads.\n"); 85 fprintf(stderr, " num_threads: how many concurrent threads.\n");
86 fprintf(stderr, " 0 or 1 for single-threaded mode,\n"); 86 fprintf(stderr, " 0 or 1 for single-threaded mode,\n");
87 fprintf(stderr, " -# to fork instead of thread.\n"); 87 fprintf(stderr, " -# to fork instead of thread.\n");
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 #endif 133 #endif
134 134
135 test_main_thread(); 135 test_main_thread();
136 136
137 if (filename) { 137 if (filename) {
138 ProfilerStop(); 138 ProfilerStop();
139 } 139 }
140 140
141 return 0; 141 return 0;
142 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698