blob: cef5232463559c7de41e9bb5cbe1560fa740f538 [file] [log] [blame]
scroggo@google.com9a412522012-09-07 15:21:18 +00001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -05008#include "bench/BenchLogger.h"
tfarinaf168b862014-06-19 12:32:29 -07009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkStream.h"
scroggo@google.com9a412522012-09-07 15:21:18 +000011
tfarinaf168b862014-06-19 12:32:29 -070012BenchLogger::BenchLogger()
halcanary96fcdcc2015-08-27 07:41:13 -070013: fFileStream(nullptr) {}
scroggo@google.com9a412522012-09-07 15:21:18 +000014
tfarinaf168b862014-06-19 12:32:29 -070015BenchLogger::~BenchLogger() {
scroggo@google.com9a412522012-09-07 15:21:18 +000016 if (fFileStream) {
halcanary385fe4d2015-08-26 13:07:48 -070017 delete fFileStream;
scroggo@google.com9a412522012-09-07 15:21:18 +000018 }
19}
20
tfarinaf168b862014-06-19 12:32:29 -070021bool BenchLogger::SetLogFile(const char *file) {
halcanary385fe4d2015-08-26 13:07:48 -070022 fFileStream = new SkFILEWStream(file);
scroggo@google.com9a412522012-09-07 15:21:18 +000023 return fFileStream->isValid();
24}
25
tfarinaf168b862014-06-19 12:32:29 -070026void BenchLogger::fileWrite(const char msg[], size_t size) {
scroggo@google.com9a412522012-09-07 15:21:18 +000027 if (fFileStream && fFileStream->isValid()) {
28 fFileStream->write(msg, size);
29 }
30}