TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
utils.h
1 /*
2  * Copyright (c) 2017-present, Facebook, Inc.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #pragma once
9 
10 #include <chrono>
11 
12 #include "language.h"
13 #include "mathutils.h"
14 #include "str.h"
15 
16 namespace common {
17 inline void setCurrentThreadName(std::string const& name) {
18 #ifdef __APPLE__
19  pthread_setname_np(name.c_str());
20 #elif __linux__
21  pthread_setname_np(pthread_self(), name.c_str());
22 #else
23  // Unsupported
24 #endif
25 }
26 
27 double memoryUsage();
28 
29 inline double timestamp(
30  std::chrono::system_clock::time_point tp =
31  std::chrono::system_clock::now()) {
32  auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(
33  tp.time_since_epoch())
34  .count();
35  return double(millis) / 1000;
36 }
37 } // namespace common
General utilities.
Definition: assert.cpp:7
void setCurrentThreadName(std::string const &name)
Definition: utils.h:17
double memoryUsage()
Definition: utils.cpp:18
double timestamp(std::chrono::system_clock::time_point tp=std::chrono::system_clock::now())
Definition: utils.h:29