aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/platform/default/tracing.cc
blob: a4ddfad928ddf49d6560f569fc81302d7da22922 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "tensorflow/core/platform/tracing.h"

#include <unistd.h>

namespace tensorflow {
namespace port {

void Tracing::RegisterEvent(EventCategory id, const char* name) {
  // TODO(opensource): implement
}

void Tracing::Initialize() {}

static bool TryGetEnv(const char* name, const char** value) {
  *value = getenv(name);
  return *value != nullptr && (*value)[0] != '\0';
}

const char* Tracing::LogDir() {
  const char* dir;
  if (TryGetEnv("TEST_TMPDIR", &dir)) return dir;
  if (TryGetEnv("TMP", &dir)) return dir;
  if (TryGetEnv("TMPDIR", &dir)) return dir;
  dir = "/tmp";
  if (access(dir, R_OK | W_OK | X_OK) == 0) return dir;
  return ".";  // Default to current directory.
}

static bool DoInit() {
  Tracing::Initialize();
  return true;
}

static const bool dummy = DoInit();

}  // namespace port
}  // namespace tensorflow