third_party.pigweed.src/pw_trace_tokenized/host_trace_time.cc
Robert Oliver 6d05de13e7 pw_trace: tokenizer basic example
Run the trace sample app and dump all trace data to a file.
- Use std::chrono::system_clock as the time source for host builds.
- Add trace_to_file.h which registers callbacks and saves all trace data
to a provided binary file.

Change-Id: I57fac75ed91fc98646e7aae920897687a39549ab
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13802
Commit-Queue: Rob Oliver <rgoliver@google.com>
Reviewed-by: (☞゚∀゚)☞ Tennessee Carmel-Veilleux  <tennessee@google.com>
2020-07-31 20:57:23 +00:00

37 lines
1.1 KiB
C++

// Copyright 2020 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
//==============================================================================
//
#include <chrono>
#include "pw_trace_tokenized/trace_tokenized.h"
using namespace std::chrono;
namespace {
auto start = system_clock::now();
} // namespace
// Define trace time as a counter for tests.
PW_TRACE_TIME_TYPE pw_trace_GetTraceTime() {
auto delta = system_clock::now() - start;
return duration_cast<microseconds>(delta).count();
}
// Microsecond time source
size_t pw_trace_GetTraceTimeTicksPerSecond() { return 1000000; }