栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

FunTester框架Redis性能测试之map & INCR

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

FunTester框架Redis性能测试之map & INCR


本篇文章接直接分享性能测试案例,分为map操作性和INCR操作。

map 思路

设计了一个简单的测试场景,用户先往某个值为map类型数据里面放一个key-value数据,然后查询这个key的value是否预期一致(其实有点多余),然后删除这个key。

这个用例实在没想到具体的适用场景,就当我为了演示空想的用例。

用例
import com.funtester.base.constaint.FixedThread
import com.funtester.base.constaint.Threadbase
import com.funtester.config.Constant
import com.funtester.db.redis.Redisbase
import com.funtester.frame.execute.Concurrent
import com.funtester.utils.StringUtil

import java.util.concurrent.atomic.AtomicInteger


class RedisList05 extends Redisbase {

    static AtomicInteger num = new AtomicInteger(0)

    static Redisbase drive

    public static void main(String[] args) {
        String host = "FunTester"
        int port = 6379
        drive = new Redisbase(host, port)
        drive.index = 2
        int times = 200
        int thread = 10
        Constant.RUNUP_TIME = 0
        def tester = new FunTester(times)

        def task = new Concurrent(tester, thread, "redis测试实践之map")
        task.start()
        drive.close()
    }

    private static class FunTester extends FixedThread {

        String key = DEFAULT_STRING + num.getAndIncrement()

        FunTester(int limit) {
            super(null, limit, true)
        }

        @Override
        protected void doing() throws Exception {
            def k = "f" + getNanoMark()
            def v = StringUtil.getString(10000)
            drive.hset(key, k, v)
            def hget = drive.hget(key, k)
            if (v != hget) fail()
            drive.hdel(key, k)
        }

        @Override
        Threadbase clone() {
            return new FunTester(this.limit)
        }
    }

}
测试结果

此处省略一千八百字和二百七十张图。

INCR

Redis Incr 命令将 key 中储存的数字值增一。而decr方式是数字值减一。这个可以设计成为两个用例。

  • 多线程对一个key进行递增操作,看是否线程安全
  • 多线程对一个可以进行等量递增和递减,看是否线程安全

为了省事儿,我只演示第一种用例。

用例
import com.funtester.base.constaint.FixedThread
import com.funtester.base.constaint.Threadbase
import com.funtester.config.Constant
import com.funtester.db.redis.Redisbase
import com.funtester.frame.execute.Concurrent

import java.util.concurrent.atomic.AtomicInteger

class RedisList06 extends Redisbase {

    static AtomicInteger num = new AtomicInteger(0)

    static Redisbase drive

    public static void main(String[] args) {
        String host = "FunTester"
        int port = 6379
        drive = new Redisbase(host, port)
        drive.index =2
        int times = 200
        int thread = 20
        Constant.RUNUP_TIME = 0
        def tester = new FunTester(times)

        def task = new Concurrent(tester, thread, "redis测试实践之INCR")
        task.start()
        drive.close()
    }

    private static class FunTester extends FixedThread {

        String listName = DEFAULT_STRING + num.getAndIncrement()

        FunTester(int limit) {
            super(null, limit, true)
        }

        @Override
        protected void doing() throws Exception {
            drive.incr("FunTester1123")
        }

        @Override
        Threadbase clone() {
            return new FunTester(this.limit)
        }
    }

}

测试结果

此处省略一千八百字。

总结

FunTester测试框架对Redis的性能测试系列已经完结,下一步会写FunTester测试框架对MySQL进行压测的实践系列,敬请期待……

最后: 可以在公众号:伤心的辣条 ! 免费领取一份216页软件测试工程师面试宝典文档资料。以及相对应的视频学习教程免费分享!,其中包括了有基础知识、Linux必备、Shell、互联网程序原理、Mysql数据库、抓包工具专题、接口测试工具、测试进阶-Python编程、Web自动化测试、APP自动化测试、接口自动化测试、测试高级持续集成、测试架构开发测试框架、性能测试、安全测试等。

如果我的博客对你有帮助、如果你喜欢我的博客内容,请 “点赞” “评论” “收藏” 一键三连哦!喜欢软件测试的小伙伴们,可以加入我们的测试技术交流扣扣群:914172719(里面有各种软件测试资源和技术讨论)


好文推荐

转行面试,跳槽面试,软件测试人员都必须知道的这几种面试技巧!

面试经:一线城市搬砖!又面软件测试岗,5000就知足了…

面试官:工作三年,还来面初级测试?恐怕你的软件测试工程师的头衔要加双引号…

什么样的人适合从事软件测试工作?

那个准点下班的人,比我先升职了…

测试岗反复跳槽,跳着跳着就跳没了…

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/301563.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号