This seems like it ought to be trivial, but I want to run a query through redis-cli, and then just get back how long it took on the server, along with the results. This is just
You can do this by wrapping the redis command you're investigating in a MULTI/EXEC
block, where the TIME
command is used right before and right after your command. For example:
Using the node library:
var multi = redis.multi();
multi.time(); // start time
multi.sunionstore(['fast_food_joints', 'pizza_hut', 'taco_bell']); // this is the command I'm investigating
multi.time(); // end time
multi.exec(function(err, responses){
var response = responses[1]; // the response i care about
var start = (parseInt(responses[0][0]) * 1000) + (parseInt(responses[0][1]) / 1000);
var end = (parseInt(responses[2][0]) * 1000) + (parseInt(responses[2][1]) / 1000);
var execution_time = end - start; // in milliseconds
});
Or... using the command line (which is what you asked for in your question):
192.168.1.1:6379> MULTI
OK
192.168.1.1:6379> TIME
QUEUED
192.168.1.1:6379> SUNIONSTORE fast_food_joints pizza_hut taco_bell
QUEUED
192.168.1.1:6379> TIME
QUEUED
192.168.1.1:6379> EXEC
1) 1) "1450818240"
2) "666636"
2) (integer) 48886
3) 1) "1450818240"
2) "666639"
And then do the math yourself. The above example took 3 microseconds.