Type | time | ms | comment |
---|---|---|---|
L1 cache reference | 0.5 ns | ||
Branch mispredict | 5 ns | ||
L2 cache reference | 7 ns | 14x L1 cache | |
Mutex lock/unlock | 25 ns | ||
Main memory reference | 300 ns | 20x L2 cache, 200x L1 cache |
This file contains hidden or 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
# Cross toolchain configuration for using clang-cl. | |
set(CMAKE_SYSTEM_NAME Windows) | |
set(CMAKE_SYSTEM_VERSION 10.0) | |
set(CMAKE_SYSTEM_PROCESSOR AMD64) | |
set(CMAKE_C_COMPILER "/usr/bin/clang-cl-9") | |
set(CMAKE_CXX_COMPILER "/usr/bin/clang-cl-9") | |
set(CMAKE_LINKER "/usr/bin/lld-link-9") |
This file contains hidden or 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
#include <condition_variable> | |
#include <cstdio> | |
#include <functional> | |
#include <future> | |
#include <iostream> | |
#include <memory> | |
#include <memory> | |
#include <mutex> | |
#include <mutex> | |
#include <queue> |
This file contains hidden or 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
default: | |
g++ -O0 -ggdb3 -std=c++11 -o example -lcds_d main.cpp -pthread | |
clear: | |
rm example |
This file contains hidden or 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
// Note: | |
// To test RedisClient, a Redis Server must be running at localhost:6479 | |
#include "RedisClient.h" | |
#include <gtest/gtest.h> | |
#include <thread> | |
template <class client_t> | |
class RedisClientTest : public testing::Test { | |
public: | |
virtual void SetUp () override { |
This file contains hidden or 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
#include <algorithm> | |
#include <cctype> | |
#include <fstream> | |
#include <iostream> | |
#include <iterator> | |
#include <set> | |
#include <string> | |
using namespace std; |
This file contains hidden or 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
#!/bin/bash | |
work_dir="/home/zampread/banker_cost" | |
date=`date +"%Y_%m_%d"` | |
data_minute=`date +"%Y_%m_%d_%H_%M"` | |
table_name="banker_record_"$date | |
output_file="banker_cost_"$data_minute | |
current_file="banker_cost_current.txt" | |
function query_mysql { |
This file contains hidden or 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
// https://leetcode.com/problems/find-k-pairs-with-smallest-sums/ | |
// a brute-force solution, just for demonstration how to get container from priority_queue | |
template <class T, | |
class Container = vector<T>, | |
class Compare = less<typename Container::value_type> > | |
class priority_queue_v2 : public priority_queue<T, Container, Compare> { | |
public: | |
using base_t = priority_queue<T, Container, Compare>; | |
priority_queue_v2(const Compare& cmp) |
This file contains hidden or 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
class Shape { | |
public: | |
virtual ~Shape() { } // A virtual destructor | |
virtual void draw() = 0; // A pure virtual function | |
virtual void move() = 0; | |
// ... | |
virtual Shape* clone() const = 0; // Uses the copy constructor | |
virtual Shape* create() const = 0; // Uses the default constructor | |
}; |
This file contains hidden or 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
project(echo_server CXX) | |
cmake_minimum_required(VERSION 2.8) | |
file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/*.cpp) | |
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g -O0 -Wall -std=c++11") | |
set(CMAKE_CXX_FLAGS "-O2 -Wall -std=c++11") | |
add_executable(echo_server | |
${SRC_FILES} | |
) |
NewerOlder