有谁试过 redis 的 string 自增性能吗, 我这怎么是个位数?

127 天前
 bthulu

我一直用这个来生成多个表公用的自增 id. 今天闲来无聊测了下, tps=10, 这有点低的离谱啊 测试代码

        ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
        Stopwatch stopwatch = Stopwatch.StartNew();
        var count = 100000;
        for (int i = 0; i < count; i++)
        {
            var id = (int)redis.GetDatabase().StringIncrement("PMDCS:id_hello");
        }
        stopwatch.Stop();
        Console.WriteLine("用时:" + stopwatch.ElapsedMilliseconds + ", tps=" + (count / stopwatch.ElapsedMilliseconds));

测试结果 用时:8357, tps=11

1632 次点击
所在节点    Redis
3 条回复
lingalonely
127 天前
ElapsedMilliseconds 不是毫秒吗,tps 是时间单位是秒呀
kuituosi
127 天前
tps*1000
huangsijun17
41 天前
tps ,Transaction per second ,每秒处理量。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1005189

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX