Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
yshekel committed Nov 19, 2024
1 parent 1b1dc7f commit d7babce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions icicle/include/icicle/utils/timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <iostream>
#include <string>
#include <chrono>
#include "icicle/utils/log.h"

/**
* @class Timer
Expand All @@ -13,6 +14,7 @@ class Timer
private:
std::chrono::time_point<std::chrono::high_resolution_clock> start_point;
std::string m_timer_name;
bool m_stopped = false;

public:
Timer(std::string timer_name)
Expand All @@ -25,12 +27,14 @@ class Timer

void Stop()
{
if (m_stopped) { return; }
auto end_point = std::chrono::high_resolution_clock::now();
auto start_time = std::chrono::time_point_cast<std::chrono::microseconds>(start_point).time_since_epoch().count();
auto end_time = std::chrono::time_point_cast<std::chrono::microseconds>(end_point).time_since_epoch().count();
auto duration = end_time - start_time;

double dur_s = duration * 0.001;
ICICLE_LOG_INFO << "Time of " << m_timer_name << ":\t" << dur_s << "ms";
m_stopped = true;
}
};
2 changes: 1 addition & 1 deletion scripts/format_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi
DIRECTORY="$1"

# Find and format all C, C++, header, and other relevant files
find "$DIRECTORY" -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.hpp' -o -name '*.cu' -o -name '*.cuh' -o -name '*.metal' | while read -r file; do
find "$DIRECTORY" -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.hpp' -o -name '*.cu' -o -name '*.cuh' -o -name '*.metal' -o -name '*.metalh'| while read -r file; do
echo "Formatting $file"
clang-format -i "$file"
done
Expand Down

0 comments on commit d7babce

Please sign in to comment.