Package redis.clients.jedis.tests;
Import Redis.clients.jedis.Jedis;
public class Jedisdemo {public static void main (string[] args) {String value = null;
Jedis Jedis = new Jedis ("localhost", 6379); Long Starttime=system.currenttimemillis ();
Gets the start time System.out.println ("Start write Test");
for (int i=0;i<1000000;i++) {jedis.set ("foo" +i, "bar" +i); Long Endtime=system.currenttimemillis ();
Get End Time System.out.println ("program Run Time:" + (Endtime-starttime) + "MS"); System.out.println ("Write per Millisecond:" +1000000/(endtime-starttime) + "bar.
"); System.out.println (write per Second: + (1000000/(endtime-starttime)) *1000+ "bar.
");
/*jedis.lpush ("foo", "Bar1");
Jedis.lpush ("foo", "Bar2");
Jedis.lpush ("foo", "Bar3"); * * SYSTEM.OUT.PRINTLN ("Start reading Test"); Starttime=system.currenttimemillis ();
Gets the start time for (int i=0;i<1000000;i++) {value = Jedis.get ("foo" +i);
System.out.println ("Value:" +value); } endtime=system.currenttimemillis (); Get End Time System.out.println ("program Run Time:" +(endtime-starttime) + "MS"); SYSTEM.OUT.PRINTLN ("read per millisecond:" +1000000/(endtime-starttime) + "bar.
"); System.out.println (read per second: + (1000000/(endtime-starttime)) *1000+ "bar.
");
Value = Jedis.get ("foo");
System.out.println ("Value:" +value);
}
}
Test results (notebook WIN7 64 bits, Redis is also using WINDOWS64 bit version):
Start Write Test
Program Run time: 73314ms
Write per millisecond: 13.
Write per second: 13,000.
Start reading tests
Program Run time: 96122ms
Read per millisecond: 10.
Read per second: 10,000.
Value:bar0