Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 | 5 |
| 6 | 6 |
| 7 /* XRay -- a simple profiler for Native Client */ | 7 /* XRay -- a simple profiler for Native Client */ |
| 8 | 8 |
| 9 #include <alloca.h> | 9 #include <alloca.h> |
| 10 #include <errno.h> | 10 #include <errno.h> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 float percent = 100.0f * (float)ticks / total; | 68 float percent = 100.0f * (float)ticks / total; |
| 69 if (percent >= percent_cutoff && ticks >= ticks_cutoff) { | 69 if (percent >= percent_cutoff && ticks >= ticks_cutoff) { |
| 70 struct XRaySymbol* symbol; | 70 struct XRaySymbol* symbol; |
| 71 symbol = XRaySymbolTableLookup(symbols, addr); | 71 symbol = XRaySymbolTableLookup(symbols, addr); |
| 72 symbol_name = XRaySymbolGetName(symbol); | 72 symbol_name = XRaySymbolGetName(symbol); |
| 73 if (0 != annotation_index) { | 73 if (0 != annotation_index) { |
| 74 XRayTraceCopyToString(capture, annotation_index, annotation); | 74 XRayTraceCopyToString(capture, annotation_index, annotation); |
| 75 } else { | 75 } else { |
| 76 strcpy(annotation, ""); | 76 strcpy(annotation, ""); |
| 77 } | 77 } |
| 78 fprintf(f, "0x%08X %10ld %5.1f %s%s %s\n", | 78 fprintf(f, "0x%08X %10lld %5.1f %s%s %s\n", |
| 79 (unsigned int)addr, (int64_t)ticks, percent, | 79 (unsigned int)addr, (int64_t)ticks, percent, |
| 80 &space[256 - depth], symbol_name, annotation); | 80 &space[256 - depth], symbol_name, annotation); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 index = XRayTraceNextEntry(capture, index); | 83 index = XRayTraceNextEntry(capture, index); |
| 84 } | 84 } |
| 85 fflush(f); | 85 fflush(f); |
| 86 } | 86 } |
| 87 | 87 |
| 88 | 88 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 108 "Frame# Total Ticks Capture size Annotations Label\n"); | 108 "Frame# Total Ticks Capture size Annotations Label\n"); |
| 109 fprintf(f, | 109 fprintf(f, |
| 110 "--------------------------------------------------------------------\n"); | 110 "--------------------------------------------------------------------\n"); |
| 111 while (frame != head) { | 111 while (frame != head) { |
| 112 int64_t total_ticks = XRayFrameGetTotalTicks(capture, frame); | 112 int64_t total_ticks = XRayFrameGetTotalTicks(capture, frame); |
| 113 int capture_size = XRayFrameGetTraceCount(capture, frame); | 113 int capture_size = XRayFrameGetTraceCount(capture, frame); |
| 114 int annotation_count = XRayFrameGetAnnotationCount(capture, frame); | 114 int annotation_count = XRayFrameGetAnnotationCount(capture, frame); |
| 115 bool valid = XRayFrameIsValid(capture, frame); | 115 bool valid = XRayFrameIsValid(capture, frame); |
| 116 char label[XRAY_MAX_LABEL]; | 116 char label[XRAY_MAX_LABEL]; |
| 117 XRayFrameMakeLabel(capture, counter, label); | 117 XRayFrameMakeLabel(capture, counter, label); |
| 118 fprintf(f, " %3d %s %10ld %10d %10d %s\n", | 118 fprintf(f, " %3d %s %10lld %10d %10d %s\n", |
| 119 counter, | 119 counter, |
| 120 valid ? " " : "*", | 120 valid ? " " : "*", |
| 121 (int64_t)total_ticks, | 121 (int64_t)total_ticks, |
| 122 capture_size, | 122 capture_size, |
| 123 annotation_count, | 123 annotation_count, |
| 124 label); | 124 label); |
| 125 totals[counter].index = counter; | 125 totals[counter].index = counter; |
| 126 totals[counter].frame = frame; | 126 totals[counter].frame = frame; |
| 127 totals[counter].ticks = total_ticks; | 127 totals[counter].ticks = total_ticks; |
| 128 total_capture += capture_size; | 128 total_capture += capture_size; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 144 fprintf(f, | 144 fprintf(f, |
| 145 "--------------------------------------------------------------------\n"); | 145 "--------------------------------------------------------------------\n"); |
| 146 for (i = 0; i < counter; ++i) { | 146 for (i = 0; i < counter; ++i) { |
| 147 int index = totals[i].index; | 147 int index = totals[i].index; |
| 148 int frame = totals[i].frame; | 148 int frame = totals[i].frame; |
| 149 int64_t total_ticks = XRayFrameGetTotalTicks(capture, frame); | 149 int64_t total_ticks = XRayFrameGetTotalTicks(capture, frame); |
| 150 int capture_size = XRayFrameGetTraceCount(capture, frame); | 150 int capture_size = XRayFrameGetTraceCount(capture, frame); |
| 151 int annotation_count = XRayFrameGetAnnotationCount(capture, frame); | 151 int annotation_count = XRayFrameGetAnnotationCount(capture, frame); |
| 152 char label[XRAY_MAX_LABEL]; | 152 char label[XRAY_MAX_LABEL]; |
| 153 XRayFrameMakeLabel(capture, index, label); | 153 XRayFrameMakeLabel(capture, index, label); |
| 154 fprintf(f, " %3d %10ld %10d %10d %s\n", | 154 fprintf(f, " %3d %10lld %10d %10d %s\n", |
| 155 index, | 155 index, |
| 156 (int64_t)total_ticks, | 156 (int64_t)total_ticks, |
| 157 capture_size, | 157 capture_size, |
| 158 annotation_count, | 158 annotation_count, |
| 159 label); | 159 label); |
| 160 } | 160 } |
| 161 fflush(f); | 161 fflush(f); |
| 162 } | 162 } |
| 163 | 163 |
| 164 | 164 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 182 frame = XRayFrameGetNext(capture, frame); | 182 frame = XRayFrameGetNext(capture, frame); |
| 183 } | 183 } |
| 184 fprintf(f, | 184 fprintf(f, |
| 185 "====================================================================\n"); | 185 "====================================================================\n"); |
| 186 #if defined(XRAY_OUTPUT_HASH_COLLISIONS) | 186 #if defined(XRAY_OUTPUT_HASH_COLLISIONS) |
| 187 XRayHashTableHisto(capture, f); | 187 XRayHashTableHisto(capture, f); |
| 188 #endif | 188 #endif |
| 189 fflush(f); | 189 fflush(f); |
| 190 } | 190 } |
| 191 | 191 |
| 192 | |
| 193 /* Write a profile report to text file. */ | 192 /* Write a profile report to text file. */ |
| 194 void XRaySaveReport(struct XRayTraceCapture* capture, | 193 void XRaySaveReport(struct XRayTraceCapture* capture, |
| 195 const char* filename, | 194 const char* filename, |
| 196 float percent_cutoff, | 195 float percent_cutoff, |
| 197 int ticks_cutoff) { | 196 int ticks_cutoff) { |
| 198 FILE* f; | 197 FILE* f; |
| 199 f = fopen(filename, "wt"); | 198 f = fopen(filename, "wt"); |
| 200 if (NULL != f) { | 199 if (NULL != f) { |
| 201 XRayReport(capture, f, percent_cutoff, ticks_cutoff); | 200 XRayReport(capture, f, percent_cutoff, ticks_cutoff); |
| 202 fclose(f); | 201 fclose(f); |
| 203 } | 202 } |
| 204 } | 203 } |
| 205 | 204 |
| 206 #endif // XRAY | 205 #endif // XRAY |
|
nfullagar1
2013/07/17 00:53:19
/* XRAY */
grosse
2013/07/17 19:37:56
Done.
| |
| OLD | NEW |