Comparison

mod_benchmark_storage/mod_benchmark_storage.lua @ 1769:f2705465cab4

mod_benchmark_storage: A storage benchmark run through prosodyctl
author Kim Alvefur <zash@zash.se>
date Thu, 18 Jun 2015 20:34:03 +0200
child 2194:136497948bf0
comparison
equal deleted inserted replaced
1768:163967467308 1769:f2705465cab4
1 -- mod_benchmark_storage
2 -- Copyright (C) 2015 Kim Alvefur
3 --
4 -- Prime numbers are pretty cool
5
6 local gettime = require"socket".gettime;
7
8 local sm = require"core.storagemanager";
9 local um = require"core.usermanager";
10 local mm = require"core.modulemanager";
11
12 local test_data, test_users;
13
14 function module.command(arg)
15 local test_driver = arg[1];
16 if not test_driver then
17 return print("Usage: prosodyctl mod_"..module.name.." <storage driver>");
18 end
19
20 sm.initialize_host("localhost");
21 um.initialize_host("localhost");
22
23 local start_time = gettime();
24 local storage = assert(sm.load_driver("localhost", test_driver));
25 storage = assert(storage:open("benchmark"));
26 -- for i = 1, 23 do
27 -- storage:set(test_users[i], test_data);
28 -- end
29 local floor, sin, random, pi = math.floor, math.sin, math.random, math.pi;
30 for i = 1, 10079 do
31 if i % 11 == 1 then
32 storage:set(test_users[i%23+1], test_data[3-floor(sin(random()*pi)*3)]);
33 else
34 storage:get(test_users[i%23+1]);
35 end
36 if i % 151 == 0 then
37 -- Give indication of progress
38 io.write("*");
39 io.flush();
40 end
41 end
42 -- Cleanup
43 for i = 1, 23 do
44 storage:set(test_users[i], nil);
45 end
46 mm.unload("localhost", "storage_"..test_driver);
47 local time_taken = gettime() - start_time;
48 io.write("\27[0G\27[K"); -- Clear current line
49 io.flush();
50 print(("Took %fs with mod_storage_%s"):format(time_taken, test_driver));
51 end
52
53 -- 23 usernames
54 test_users = {
55 "tritonymph"; "ankylotomy"; "tron"; "barbaric"; "twiddler";
56 "spiritful"; "unmollifiably"; "suggestion"; "presubsistence";
57 "unneeded"; "taxemic"; "teloteropathic"; "nonbending"; "mev";
58 "septifragally"; "clame"; "obsolescent"; "unconceivable";
59 "foolishly"; "conjunctur"; "precirculation"; "bethump"; "vermivorous";
60 };
61
62 test_data = {
63 { some_data = "tiny data" };
64 --
65 { [false] = { version = 1; pending = {}; }; -- Medium data
66 ["user@example.com"] = { subscription = "both"; groups = {};
67 name = "My Best Friend"; }; };
68 --
69 { attr = { xmlns = "vcard-temp"; }; name = "vCard"; -- The largest data
70 { attr = { xmlns = "vcard-temp"; }; name = "NICKNAME"; "Buster"; };
71 { attr = { xmlns = "vcard-temp"; }; name = "PHOTO";
72 { attr = { xmlns = "vcard-temp"; }; name = "TYPE"; "image/jpeg"; };
73 { attr = { xmlns = "vcard-temp"; }; name = "BINVAL"; [[
74 /9j/4AAQSkZJRgABAgAAZABkAAD/2wBDAAgFBQUGBQgGBggLBwYHCw0JCAgJDQ8MDA0MDA8RDAwM
75 DAwMEQ4RERIREQ4XFxgYFxcgICAgICQkJCQkJCQkJCT/2wBDAQgICA8ODxwTExwfGRQZHyQkJCQk
76 JCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCT/wAARCAA8ADwDAREA
77 AhEBAxEB/8QAGwAAAgMBAQEAAAAAAAAAAAAABgcDBAUCCAH/xAA9EAACAQIEAgcECAMJAAAAAAAB
78 AgMEEQAFEhMGIQcUFSIxQWEWQlFSIyQyM2JxgZElcqEXJjSCksHR8PH/xAAbAQACAwEBAQAAAAAA
79 AAAAAAAEBQECAwYAB//EADcRAAEDAwIDBAcGBwAAAAAAAAEAAgMEESESMQUTQSJRYYEUIzJCcaGx
80 BhUWkdHhQ1JyguLw8f/aAAwDAQACEQMRAD8ASI+7+N8WVuiNuiPgaHinPXkr115TloWWpjvbedj9
81 FCT8psS3py88I+N8SNPHZvtu28PFFU0Oo36L0dDTxQxrHGqpEgCoigBVUCwVQPADHz3ckndMLr7M
82 jFOSsR5BL3v5eF8edfyUtOVVENZJGdcDR8ySTc8v1APP8sYPjwStg9oO4Q/xTw9Q5vl0tFXw7tPI
83 De47ynyeNvJlPhgrhde6CQ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