gpt4 book ai didi

testing - 如何一次对 Redis 的所有操作进行基准测试

转载 作者:可可西里 更新时间:2023-11-01 11:48:22 25 4
gpt4 key购买 nike

当我尝试使用默认基准测试 redis 时,所有操作都在一个接一个地执行,有没有办法并行执行所有操作?

最佳答案

我在nodejs和express中使用了redis api,并使用jmeter进行了测试。

这是我的代码,

    var express = require('express');
var app = express();

var redis = require("redis"),
client = redis.createClient(6379,"10.96.82.175");

app.get('/', function (req, res) {
res.send("HEY Nodejs runnning on 10.96.82.175:4000");
});

app.put('/set/:arg1/:arg2', function (req, res) {

client.set( req.params.arg1,req.params.arg2,function (err, reply) {
if (reply==null)
{
res.send("null");
}
else {
res.send(reply.toString());
}

});
});


app.get('/get/:arg1', function (req, res) {
client.get( req.params.arg1,function (err, reply) {

if (reply==null)
{
res.send("null");
}
else {
res.send(reply.toString());
}

});
});






app.get('/incr/:arg1', function (req, res) {
client.incr(req.params.arg1, function (err, reply) {
if (reply==null)
{
res.send("null");
}
else {
res.send(reply.toString());
}

//console.log(reply.toString());
});
});





app.put('/lpush/:arg1/:arg2', function (req, res) {
client.lpush(req.params.arg1,req.params.arg2, function (err, reply) {
if (reply==null)
{
res.send("null");
}
else {
res.send(reply.toString());
}

//console.log(reply.toString());
});
});



app.get('/lpop/:arg1', function (req, res) {
client.lpop(req.params.arg1, function (err, reply) {

if (reply==null)
{
res.send("null");
}
else {
res.send(reply.toString());
}
});
});



app.put('/sadd/:arg1/:arg2', function (req, res) {
client.sadd(req.params.arg1,req.params.arg2, function (err, reply) {
if (reply==null)
{
res.send("null");
}
else {
res.send(reply.toString());
}
//console.log(reply.toString());
});
});




app.get('/spop/:arg1', function (req, res) {
client.spop(req.params.arg1,1, function (err, reply) {

if (reply==null)
{
res.send("null");
}
else {
res.send(reply.toString());
}
//console.log(reply.toString());
});
});


app.put('/zadd/:arg1/:arg2/:arg3', function (req, res) {
client.zadd(req.params.arg1,req.params.arg2,req.params.arg3,function (err, reply) {
if (reply==null)
{
res.send("null");
}
else {
res.send(reply.toString());
}
//console.log(reply.toString());
});
});

app.put('/hset/:arg1/:arg2/:arg3', function (req, res) {
client.hset(req.params.arg1,req.params.arg2,req.params.arg3,function (err, reply) {
if (reply==null)
{
res.send("null");
}
else {
res.send(reply.toString());
}
//console.log(reply.toString());
});
});

app.get('/hget/:arg1/:arg2', function (req, res) {

client.hget(req.params.arg1,req.params.arg2,function (err, reply) {

if (reply==null)
{
res.send("null");
}
else {
res.send(reply.toString());
}
//console.log(reply);
});
});

app.listen(4000, function () {

console.log('Example app listening on port 4000!');
});

这是我的 jmx 文件

JMX FILE LINK

关于testing - 如何一次对 Redis 的所有操作进行基准测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39010434/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com