comparison mod_benchmark_storage/mod_benchmark_storage.lua @ 2194:136497948bf0

mod_benchmark_storage: Put hostname in a variable
author Kim Alvefur <zash@zash.se>
date Wed, 01 Jun 2016 14:33:57 +0200
parents f2705465cab4
children 967ba20e1202
comparison
equal deleted inserted replaced
2193:40824a38d505 2194:136497948bf0
15 local test_driver = arg[1]; 15 local test_driver = arg[1];
16 if not test_driver then 16 if not test_driver then
17 return print("Usage: prosodyctl mod_"..module.name.." <storage driver>"); 17 return print("Usage: prosodyctl mod_"..module.name.." <storage driver>");
18 end 18 end
19 19
20 sm.initialize_host("localhost"); 20 local hostname = "localhost";
21 um.initialize_host("localhost"); 21
22 sm.initialize_host(hostname);
23 um.initialize_host(hostname);
22 24
23 local start_time = gettime(); 25 local start_time = gettime();
24 local storage = assert(sm.load_driver("localhost", test_driver)); 26 local storage = assert(sm.load_driver(hostname, test_driver));
25 storage = assert(storage:open("benchmark")); 27 storage = assert(storage:open("benchmark"));
26 -- for i = 1, 23 do 28 -- for i = 1, 23 do
27 -- storage:set(test_users[i], test_data); 29 -- storage:set(test_users[i], test_data);
28 -- end 30 -- end
29 local floor, sin, random, pi = math.floor, math.sin, math.random, math.pi; 31 local floor, sin, random, pi = math.floor, math.sin, math.random, math.pi;
41 end 43 end
42 -- Cleanup 44 -- Cleanup
43 for i = 1, 23 do 45 for i = 1, 23 do
44 storage:set(test_users[i], nil); 46 storage:set(test_users[i], nil);
45 end 47 end
46 mm.unload("localhost", "storage_"..test_driver); 48 mm.unload(hostname, "storage_"..test_driver);
47 local time_taken = gettime() - start_time; 49 local time_taken = gettime() - start_time;
48 io.write("\27[0G\27[K"); -- Clear current line 50 io.write("\27[0G\27[K"); -- Clear current line
49 io.flush(); 51 io.flush();
50 print(("Took %fs with mod_storage_%s"):format(time_taken, test_driver)); 52 print(("Took %fs with mod_storage_%s"):format(time_taken, test_driver));
51 end 53 end