mirror of
https://github.com/EQEmu/Server.git
synced 2026-01-22 04:33:58 +00:00
Updated Data Buckets (markdown)
parent
103130222f
commit
c92fae1277
@ -164,4 +164,56 @@ end
|
||||
|
||||
```perl
|
||||
quest::set_data("my_example_flag", "some_value", time() + 3600); # 3600 seconds = 1 hour (Expire in 1 hour)
|
||||
```
|
||||
|
||||
# Benchmarks
|
||||
|
||||
* Below are some simple benchmarks used to calculate performance. While even these numbers could be greatly optimized yet, these are plenty good for most use cases that server operators need. If you need even faster temporary data storage within the context of a zone, I would suggest using [[Entity Variables]] as they operate purely in memory
|
||||
|
||||

|
||||
|
||||
```perl
|
||||
sub EVENT_SAY {
|
||||
use Time::HiRes;
|
||||
my $start = [ Time::HiRes::gettimeofday() ];
|
||||
|
||||
if ($text =~ /random-write/i) {
|
||||
my $iterations = 1000;
|
||||
my $key_range = 100;
|
||||
quest::debug("Testing random-write... Iterations: (" . plugin::commify($iterations) . ") Key Range: " . $key_range);
|
||||
for ($i = 0; $i < $iterations; $i++) {
|
||||
quest::set_data("key_" . int(rand($key_range)), &generate_random_string(100), time());
|
||||
}
|
||||
}
|
||||
|
||||
if ($text =~ /sequential-write/i) {
|
||||
my $iterations = 1000;
|
||||
quest::debug("Testing sequential-write... Iterations: (" . plugin::commify($iterations) . ")");
|
||||
for ($i = 0; $i < $iterations; $i++) {
|
||||
quest::set_data("key_" . $i, &generate_random_string(100), time() + 15);
|
||||
}
|
||||
}
|
||||
|
||||
if ($text =~ /sequential-read/i) {
|
||||
my $iterations = 1000;
|
||||
quest::debug("Testing sequential-read... Iterations: (" . plugin::commify($iterations) . ")");
|
||||
for ($i = 0; $i < $iterations; $i++) {
|
||||
$data = quest::get_data("key_" . $i);
|
||||
# if ($data ne "") {
|
||||
# quest::say("Data for $i : $data");
|
||||
# }
|
||||
}
|
||||
}
|
||||
|
||||
if ($text =~ /random-read/i) {
|
||||
my $iterations = 1000;
|
||||
quest::debug("Testing random-read... Iterations: (" . plugin::commify($iterations) . ")");
|
||||
for ($i = 0; $i < $iterations; $i++) {
|
||||
$data = quest::get_data("key_" . int(rand($iterations)));
|
||||
}
|
||||
}
|
||||
|
||||
my $elapsed = Time::HiRes::tv_interval($start);
|
||||
quest::debug("Operation took: " . $elapsed);
|
||||
}
|
||||
```
|
||||
Loading…
x
Reference in New Issue
Block a user