//========================================================
【LevelDB源码剖析系列】SkipList与Memtable
日本麻将的库,“求向听数”、“判断胡牌”、“牌面拆解”采用查表法。
麻将胡牌算法以及AI算法
https://www.oschina.net/news/94883/majiang-algorithm-1-0-8-released?from=singlemessage
https://github.com/esrrhs/majiang_algorithm
系列教程
Memcached源码分析 - Memcached源码分析之总结篇(8)
Memcached源码解析
Memcached源码分析
学习笔记:The Log(我所读过的最好的一篇分布式技术文章)
http://www.cnblogs.com/foreach-break/p/notes_about_distributed_system_and_The_log.html
Raft资料
实现例子
https://raft.github.io/#implementations
https://github.com/guangqianpeng
paxos
http://chenneal.github.io/2017/03/16/phxpaxos%E6%BA%90%E7%A0%81%E9%98%85%E8%AF%BB%E4%B9%8B%E4%B8%80%EF%BC%9A%E8%B5%B0%E9%A9%AC%E8%A7%82%E8%8A%B1/
https://github.com/Tencent/phxpaxos/wiki/%E7%AC%AC%E4%B8%89%E6%96%B9%E6%96%87%E7%AB%A0%E6%B1%87%E9%9B%86%E4%BB%A5%E5%8F%8A%E5%B8%AE%E5%8A%A9
地址内容一致
计算时间的样例 来自 https://github.com/peng1ei/MeasureAlgoTime
1 // 2 // Created by penglei on 18-9-29. 3 // 4 5 #ifndef TOOLS_MEASUREALGOTIME_HPP 6 #define TOOLS_MEASUREALGOTIME_HPP 7 8 #include <chrono> 9 #include <type_traits> 10 #include <iostream> 11 12 namespace Tools { 13 14 namespace Time { 15 16 using ns = std::chrono::nanoseconds; 17 using us = std::chrono::microseconds; 18 using ms = std::chrono::milliseconds; 19 using s = std::chrono::seconds; 20 using m = std::chrono::minutes; 21 using h = std::chrono::hours; 22 23 template <typename DurationType> class AlgoTime; 24 using AlgoTimeNs = AlgoTime<ns>; 25 using AlgoTimeUs = AlgoTime<us>; 26 using AlgoTimeMs = AlgoTime<ms>; 27 using AlgoTimeS = AlgoTime<s>; 28 using AlgoTimeM = AlgoTime<m>; 29 using AlgoTimeH = AlgoTime<h>; 30 31 /** 32 * 用于计算代码运行的时间 33 * @tparam DurationType 类似于时间单位,默认以“毫秒”为单位 34 */ 35 template <typename DurationType = ms> 36 class AlgoTime { 37 public: 38 void start() { 39 start_ = std::chrono::steady_clock::now(); 40 } 41 42 typename DurationType::rep elapsed() const { 43 auto elapsed = std::chrono::duration_cast<DurationType>( 44 std::chrono::steady_clock::now() - start_); 45 return elapsed.count(); 46 } 47 48 void printElapsed() { 49 auto time = elapsed(); 50 51 if (std::is_same<DurationType, ns>::value) { 52 std::cout << std::endl << "[AlgoTime: " << time << " ns]" << std::endl; 53 } else if (std::is_same<DurationType, us>::value) { 54 std::cout << std::endl << "[AlgoTime: " << time << " us]" << std::endl; 55 } else if (std::is_same<DurationType, ms>::value) { 56 std::cout << std::endl << "[AlgoTime: " << time << " ms]" << std::endl; 57 } else if (std::is_same<DurationType, s>::value) { 58 std::cout << std::endl << "[AlgoTime: " << time << " s]" << std::endl; 59 } else if (std::is_same<DurationType, m>::value) { 60 std::cout << std::endl << "[AlgoTime: " << time << " m]" << std::endl; 61 } else if (std::is_same<DurationType, h>::value) { 62 std::cout << std::endl << "[AlgoTime: " << time << " h]" << std::endl; 63 } 64 } 65 66 private: 67 std::chrono::steady_clock::time_point start_; 68 }; 69 70 } // namespace Time 71 72 } // namespace Tools 73 74 #endif //TOOLS_MEASUREALGOTIME_HPP
1 #include "MeasureAlgoTime.hpp" 2 3 int main() { 4 5 // 创建一个以“微秒”为单位的算法时间对象 6 // 当然也可以使用其它时间单位的时间对象,如毫秒、秒等 7 Tools::Time::AlgoTimeUs time; 8 9 // 启动计时 10 time.start(); 11 for (int i = 0; i < 1024; ++i) { 12 std::cout << "hello C++11 !" << std::endl; 13 } 14 15 // 直接在标准输出设备中输出程序的运行时间 16 time.printElapsed(); 17 18 // 或者使用以下方式进行运行时间的输出 19 auto elapsed = time.elapsed(); 20 std::cout << elapsed << "us" << std::endl; 21 22 return 0; 23 }