timer-benchmarks
                                
                                 timer-benchmarks copied to clipboard
                                
                                    timer-benchmarks copied to clipboard
                            
                            
                            
                        换 flat hash map 提升性能
下面测试替换我实现的hash map. 性能提升比较明显https://github.com/ktprime/emhash/blob/master/hash_table5.hpp
D:\timer-benchmarks-master\test\BenchTimer.cpp relative time/iter iters/s
PQTimerAdd 17.27ms 57.89 TreeTimerAdd 76.74% 22.51ms 44.42 WheelTimerAdd 113.68% 15.20ms 65.81
PQTimerDel 12.65ms 79.08 TreeTimerDel 113.87m% 11.11s 90.04m WheelTimerDel 159.14% 7.95ms 125.85
PQTimerTick 3.67ms 272.61 TreeTimerTick 70.78% 5.18ms 192.94 WheelTimerTick 58.32% 6.29ms 158.98
PQTimerAdd 12.44ms 80.38 TreeTimerAdd 55.98% 22.22ms 45.00 WheelTimerAdd 119.79% 10.39ms 96.28
PQTimerDel 7.73ms 129.29 TreeTimerDel 68.57m% 11.28s 88.65m WheelTimerDel 157.01% 4.93ms 203.01
PQTimerTick 2.17ms 461.49 TreeTimerTick 38.52% 5.63ms 177.75 WheelTimerTick 46.62% 4.65ms 215.16
很不错的优化
再次优化性能,发现一些bug并修复,在我的个人 项目上,
用hash分桶 实现另外一种定时器,性能和时间轮差别不大并成功应用到quic 项目的定时器中(定时器结构复用,hash不删除,只设置失效时间为0)
但不支持相同超时的定时器按FIFO顺序触发; 节点优先级比较实现一下就能达到目的,比如按插入序号,时间之类的。