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

Side by Side Diff: bench/SkBenchLogger.h

Issue 347823004: Remove Sk prefix from some bench classes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkGMBench -> GMBench Created 6 years, 6 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
« no previous file with comments | « bench/ShaderMaskBench.cpp ('k') | bench/SkBenchLogger.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2012 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9 #ifndef SkBenchLogger_DEFINED
10 #define SkBenchLogger_DEFINED
11
12 #include "SkTypes.h"
13 #include "SkString.h"
14 #include <stdio.h>
15
16 class SkFILEWStream;
17
18 /**
19 * Class that allows logging to a file while simultaneously logging to stdout/st derr.
20 */
21 class SkBenchLogger {
22 public:
23 SkBenchLogger();
24
25 /**
26 * Not virtual, since this class is not intended to be subclassed.
27 */
28 ~SkBenchLogger();
29
30 /**
31 * Specify a file to write progress logs to. Unless this is called with a va lid file path,
32 * SkBenchLogger will only write to stdout/stderr.
33 */
34 bool SetLogFile(const char file[]);
35
36 /**
37 * Log an error to stderr, taking a C style string as input.
38 */
39 void logError(const char msg[]) { this->nativeLogError(msg); }
40
41 /**
42 * Log an error to stderr, taking an SkString as input.
43 */
44 void logError(const SkString& str) { this->nativeLogError(str.c_str()); }
45
46 /**
47 * Log the progress of the bench tool to both stdout and the log file specif ied by SetLogFile,
48 * if any, taking a C style string as input.
49 */
50 void logProgress(const char msg[]) {
51 this->nativeLogProgress(msg);
52 this->fileWrite(msg, strlen(msg));
53 }
54
55 /**
56 * Log the progress of the bench tool to both stdout and the log file specif ied by SetLogFile,
57 * if any, taking an SkString as input.
58 */
59 void logProgress(const SkString& str) {
60 this->nativeLogProgress(str.c_str());
61 this->fileWrite(str.c_str(), str.size());
62 }
63
64 private:
65 #ifdef SK_BUILD_FOR_ANDROID
66 void nativeLogError(const char msg[]) { SkDebugf("%s", msg); }
67 #else
68 void nativeLogError(const char msg[]) { fprintf(stderr, "%s", msg); }
69 #endif
70 void nativeLogProgress(const char msg[]) { SkDebugf("%s", msg); }
71
72 void fileWrite(const char msg[], size_t size);
73
74 SkFILEWStream* fFileStream;
75 };
76
77 #endif // SkBenchLogger_DEFINED
OLDNEW
« no previous file with comments | « bench/ShaderMaskBench.cpp ('k') | bench/SkBenchLogger.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698