Skip to content

Instantly share code, notes, and snippets.

View utilForever's full-sized avatar

Chris Ohk utilForever

View GitHub Profile
@utilForever
utilForever / insensitive_string_match.cpp
Last active March 22, 2017 09:53
Store std::string in std::map w/ and w/o lowercase process, and find arbitrary string using various methods (Insensitive case)
#include <algorithm>
#include <cctype>
#include <chrono>
#include <fstream>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <vector>
@utilForever
utilForever / ReplaceWCSWithPattern.cpp
Created June 14, 2017 09:10
Replace some pattern in std::wstring with another pattern
std::wstring ReplaceWCSWithPattern(__in const std::wstring &message, __in const std::wstring &pattern, __in const std::wstring &replace)
{
std::wstring result = message;
std::wstring::size_type pos = 0;
std::wstring::size_type offset = 0;
while ((pos = result.find(pattern, offset)) != std::wstring::npos)
{
result.replace(result.begin() + pos, result.begin() + pos + pattern.size(), replace);
offset = pos + replace.size();
@utilForever
utilForever / AbsMinMax.h
Last active June 15, 2017 03:54
Implement AbsMin(), AbsMax() function for std::array
//!
//! \brief Returns the absolute minimum value among the elements in std::array.
//!
//! \param[in] arr The array.
//!
//! \tparam T Value type.
//!
//! \return The absolute minimum.
//!
template <typename T, int N>
@utilForever
utilForever / move_semantics.cpp
Created August 22, 2017 12:26
Examples for move semantics (C++11)
#include <string>
#include <iostream>
#include <iomanip>
#include <utility>
struct A
{
std::string s;
A() : s("test") { }
A(const A& o) : s(o.s) { std::cout << "move failed!\n"; }
@utilForever
utilForever / StructuredBindings.cpp
Created October 19, 2017 04:56
Examples for C++17 structured bindings
#include <iostream>
#include <tuple>
int main()
{
auto tuple = std::make_tuple(1, 'a', 2.3);
// unpack the tuple into individual variables declared at the call site
auto[i, c, d] = tuple;
@utilForever
utilForever / move_semantics.cpp
Created October 22, 2017 15:53
Rvalue reference, move semantics, std::move example
#include <iostream>
#include <algorithm>
class A
{
public:
// Simple constructor that initializes the resource.
explicit A(size_t length)
: mLength(length), mData(new int[length])
@utilForever
utilForever / TimePerfTests-OpenMP.txt
Last active April 21, 2018 16:13
CubbyFlow Time Performance Test Result - OpenMP
Run on (12 X 3298 MHz CPU s)
CPU Caches:
L1 Data 32K (x6)
L1 Instruction 32K (x6)
L2 Unified 262K (x6)
L3 Unified 15728K (x1)
--------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
--------------------------------------------------------------------------------------------------
BVH3/Nearest 138131 ns 138108 ns 7467
@utilForever
utilForever / MemPerfTests-OpenMP.txt
Last active April 21, 2018 16:13
CubbyFlow Memory Performance Tests - OpenMP
[==========] Running 7 tests from 4 test cases.
[----------] Global test environment set-up.
[----------] 1 test from FDMICCGSolver3
[ RUN ] FDMICCGSolver3.Memory
[ STAT ] Mem usage: 2.414410 GB.
[ OK ] FDMICCGSolver3.Memory (7952 ms)
[----------] 1 test from FDMICCGSolver3 (7953 ms total)
[----------] 1 test from FLIPSolver3
[ RUN ] FLIPSolver3.Memory
@utilForever
utilForever / TimePerfTests-IntelTBB.txt
Created April 21, 2018 16:27
CubbyFlow Time Performance Test Result - Intel TBB
Run on (12 X 3298 MHz CPU s)
CPU Caches:
L1 Data 32K (x6)
L1 Instruction 32K (x6)
L2 Unified 262K (x6)
L3 Unified 15728K (x1)
--------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
--------------------------------------------------------------------------------------------------
BVH3/Nearest 130629 ns 129395 ns 6400
@utilForever
utilForever / UnitTests-OpenMP.txt
Created April 24, 2018 09:24
CubbyFlow Unit Tests - OpenMP
[==========] Running 761 tests from 160 test cases.
[----------] Global test environment set-up.
[----------] 1 test from APICSolver2
[ RUN ] APICSolver2.UpdateEmpty
[ OK ] APICSolver2.UpdateEmpty (19 ms)
[----------] 1 test from APICSolver2 (21 ms total)
[----------] 1 test from APICSolver3
[ RUN ] APICSolver3.UpdateEmpty
[ OK ] APICSolver3.UpdateEmpty (24 ms)