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

2007 篇文章 51 订阅
1227 篇文章 21 订阅

在这里插入图片描述
本篇文章接直接分享性能测试案例,分为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

/**
 * FunTester测试框架,Redis压测,map
 */
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
/**
 * FunTester测试框架,Redis压测,incr
 */
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)
        }
    }

}

测试结果

此处省略一千八百字。

incr结果验证

总结

FunTester测试框架对Redis的性能测试系列已经完结,下一步会写FunTester测试框架对MySQL进行压测的实践系列,敬请期待……
在这里插入图片描述

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

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


好文推荐

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

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

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

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

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

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值