license.bot | f003cfe | 2008-08-24 09:55:55 +0900 | [diff] [blame^] | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 4 | |
| 5 | #include <stdio.h> |
| 6 | #include <shlwapi.h> |
| 7 | #include <windows.h> |
| 8 | |
| 9 | #include "base/perftimer.h" |
| 10 | |
| 11 | #include "base/logging.h" |
| 12 | #include "base/basictypes.h" |
| 13 | |
| 14 | static FILE* perf_log_file = NULL; |
| 15 | |
| 16 | bool InitPerfLog(const char* log_file) { |
| 17 | if (perf_log_file) { |
| 18 | // trying to initialize twice |
| 19 | NOTREACHED(); |
| 20 | return false; |
| 21 | } |
| 22 | |
| 23 | return fopen_s(&perf_log_file, log_file, "w") == 0; |
| 24 | } |
| 25 | |
| 26 | void FinalizePerfLog() { |
| 27 | if (!perf_log_file) { |
| 28 | // trying to cleanup without initializing |
| 29 | NOTREACHED(); |
| 30 | return; |
| 31 | } |
| 32 | fclose(perf_log_file); |
| 33 | } |
| 34 | |
| 35 | void LogPerfResult(const char* test_name, double value, const char* units) { |
| 36 | if (!perf_log_file) { |
| 37 | NOTREACHED(); |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | fprintf(perf_log_file, "%s\t%g\t%s\n", test_name, value, units); |
| 42 | printf("%s\t%g\t%s\n", test_name, value, units); |
| 43 | } |
| 44 | |
license.bot | f003cfe | 2008-08-24 09:55:55 +0900 | [diff] [blame^] | 45 | |