scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "bench/BenchLogger.h" |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/core/SkStream.h" |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 11 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 12 | BenchLogger::BenchLogger() |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 13 | : fFileStream(nullptr) {} |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 14 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 15 | BenchLogger::~BenchLogger() { |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 16 | if (fFileStream) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 17 | delete fFileStream; |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 18 | } |
| 19 | } |
| 20 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 21 | bool BenchLogger::SetLogFile(const char *file) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 22 | fFileStream = new SkFILEWStream(file); |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 23 | return fFileStream->isValid(); |
| 24 | } |
| 25 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 26 | void BenchLogger::fileWrite(const char msg[], size_t size) { |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 27 | if (fFileStream && fFileStream->isValid()) { |
| 28 | fFileStream->write(msg, size); |
| 29 | } |
| 30 | } |