-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Component categories and table statistics.
- Loading branch information
Showing
16 changed files
with
311 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
struct CoInit | ||
{ | ||
CoInit() | ||
{ | ||
CoInitialize(nullptr); | ||
} | ||
|
||
~CoInit() | ||
{ | ||
CoUninitialize(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "kvstorelib.h" | ||
#include "timer.h" | ||
|
||
Timer::Timer() | ||
{ | ||
start_ = Clock::now(); | ||
} | ||
|
||
std::string Timer::str() const | ||
{ | ||
using std::chrono::duration_cast; | ||
auto now = Clock::now(); | ||
|
||
auto elapsed = duration_cast<std::chrono::milliseconds>(now - start_).count(); | ||
|
||
auto hours = (elapsed / 1000) / 3600; | ||
auto minutes = ((elapsed / 1000) % 3600) / 60; | ||
auto seconds = (elapsed / 1000) % 60; | ||
auto millis = elapsed % 1000; | ||
|
||
boost::format fmt; | ||
|
||
if (hours) | ||
fmt = boost::format("%d:%02d:%02d hours") % hours % minutes % seconds; | ||
else if (minutes) | ||
fmt = boost::format("%d:%02d minutes") % minutes % seconds; | ||
else | ||
fmt = boost::format("%d.%03d seconds") % seconds % millis; | ||
|
||
return fmt.str(); | ||
} | ||
|
||
void Timer::restart() | ||
{ | ||
start_ = Clock::now(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include <chrono> | ||
|
||
class Timer | ||
{ | ||
public: | ||
Timer(); | ||
~Timer() = default; | ||
|
||
void restart(); | ||
std::string str() const; | ||
|
||
private: | ||
using Clock = std::chrono::high_resolution_clock; | ||
using TimePoint = std::chrono::time_point<std::chrono::high_resolution_clock>; | ||
TimePoint start_; | ||
}; | ||
|
||
inline std::ostream& operator<<(std::ostream& s, const Timer& timer) | ||
{ | ||
return s << timer.str(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "kvstorelib.h" | ||
#include "util.h" | ||
|
||
namespace utility { | ||
|
||
std::string comma(uint64_t i) | ||
{ | ||
std::ostringstream os; | ||
|
||
std::ostringstream ss; | ||
ss << i; | ||
auto input = ss.str(); | ||
|
||
auto n = static_cast<int>(input.length()); | ||
|
||
for (auto j = n - 1, k = 1; j >= 0; j--, k++) { | ||
os << input[j]; | ||
if (k % 3 == 0 && j > 0 && j < n - 1) { | ||
os << ','; | ||
} | ||
} | ||
|
||
auto output(os.str()); | ||
reverse(output.begin(), output.end()); | ||
|
||
return output; | ||
} | ||
|
||
} // utility |
Oops, something went wrong.