bthulu
V2EX  ›  Redis

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

  •  
  •   bthulu · Jan 2, 2024 · 5241 views
    This topic created in 864 days ago, the information mentioned may be changed or developed.

    我一直用这个来生成多个表公用的自增 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

    3 replies    2024-03-28 16:15:32 +08:00
    lingalonely
        1
    lingalonely  
       Jan 2, 2024
    ElapsedMilliseconds 不是毫秒吗,tps 是时间单位是秒呀
    kuituosi
        2
    kuituosi  
       Jan 2, 2024
    tps*1000
    huangsijun17
        3
    huangsijun17  
       Mar 28, 2024
    tps ,Transaction per second ,每秒处理量。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2953 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 05:58 · PVG 13:58 · LAX 22:58 · JFK 01:58
    ♥ Do have faith in what you're doing.