V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
bthulu
V2EX  ?  Redis

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

  •  
  •   bthulu · 125 天前 · 1626 次点击
    这是一个创建于 125 天前的主题,其中的信息可能已经有所发展或是发生改变。

    腾讯云最新优惠活动来了:云产品限时1折,云服务器低至88元/年 ,点击这里立即抢购:9i0i.cn/qcloud,更有2860元代金券免费领取,付款直接抵现金用,点击这里立即领取:9i0i.cn/qcloudquan

    (福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

    我一直用这个来生成多个表公用的自增 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 条回复  ?  2024-03-28 16:15:32 +08:00
    lingalonely
        1
    lingalonely  
       125 天前
    ElapsedMilliseconds 不是毫秒吗,tps 是时间单位是秒呀
    kuituosi
        2
    kuituosi  
       125 天前
    tps*1000
    huangsijun17
        3
    huangsijun17  
       39 天前
    tps ,Transaction per second ,每秒处理量。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1096 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 22:53 · PVG 06:53 · LAX 15:53 · JFK 18:53
    Developed with CodeLauncher
    ? Do have faith in what you're doing.


    http://www.vxiaotou.com