// File: /workspace/github_cpp_makefile_star2_O3/dustin[P]kvtest/tests.cc
// Function: EnduranceTest::run(kvtest::KVStore*)
bool EnduranceTest::run(KVStore *tut) {
    long i = 0, prev_calls = 0;
    CountingCallback cb;
    time_t start = time(NULL);
    time_t step = time(NULL);
    const int alarm_freq = 10;
    Keys k(30000);
    Values v(20, 40000, 60000);

    setup_alarm(alarm_freq);

    std::cout << "# start time:  " << start << std::endl;
    std::cout << "# cmds\tbacklog\ttime\tabstime\trate" << std::endl;

    for(i = 0 ; ; i++) {
        std::string key(k.nextKey());
        const char *value = v.nextValue();

        tut->set(key, value, cb);
        if (alarmed) {
            time_t now = time(NULL);
            int delta = (int)(now - step);
            long new_calls = i - prev_calls;
            step = now;
            std::cout << i << "\t" << (i - cb.num_calls() + 1)
                      << "\t" << delta << "\t" << now << "\t"
                      << ((double)new_calls / (double)delta) << std::endl
                      << std::flush;
            prev_calls = i;
            setup_alarm(alarm_freq);
        }
    }

    // Last one to wait for a commit.
    RememberingCallback<bool> cbLast;
    tut->noop(cbLast);
    cbLast.waitForValue();
    time_t end = time(NULL);

    assertEquals((int)i, cb.num_calls());

    int delta = (int)(end - start);
    std::cout << "Ran " << i << " operations in "
              << delta << "s ("
              << (i/delta) << " ops/s)"
              << std::endl;
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rsi, %rbx
leaq 0x68(%rsp), %rdi
callq 0x58d4
xorl %edi, %edi
callq 0x3230
movq %rax, %r14
xorl %edi, %edi
callq 0x3230
movq %rax, %r15
leaq 0x28(%rsp), %rdi
movl $0x7530, %esi           # imm = 0x7530
callq 0x6260
leaq 0x48(%rsp), %rdi
movl $0x14, %esi
movl $0x9c40, %edx           # imm = 0x9C40
movl $0xea60, %ecx           # imm = 0xEA60
callq 0x6490
leaq 0x2e1(%rip), %rax       # 0x535c
leaq 0xa0(%rsp), %rsi
movq %rax, (%rsi)
movl $0x0, 0x88(%rsi)
movl $0xe, %edi
xorl %edx, %edx
callq 0x3310
movb $0x0, 0x71b0(%rip)      # 0xc253
movl $0xa, %edi
callq 0x3420
movq 0x6f14(%rip), %rdi      # 0xbfc8
leaq 0x30b2(%rip), %rsi      # 0x816d
movl $0xf, %edx
callq 0x32a0
movq 0x6efc(%rip), %rdi      # 0xbfc8
movq %r14, %rsi
callq 0x3240
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x6ec3(%rip), %rdi      # 0xbfc8
leaq 0x3071(%rip), %rsi      # 0x817d
movl $0x20, %edx
callq 0x32a0
movq 0x6eab(%rip), %rdi      # 0xbfc8
callq 0x30f0
leaq 0x10(%rsp), %rbp
xorl %r13d, %r13d
leaq 0x28(%rsp), %r14
xorl %r12d, %r12d
movq %rbx, 0x20(%rsp)
movq %r14, %rdi
callq 0x63bc
movq %rsp, %rdi
movq %rax, %rsi
leaq 0xa0(%rsp), %rdx
callq 0x3e2e
leaq 0x48(%rsp), %rdi
callq 0x6662
movq (%rbx), %r8
movq %rbx, %rdi
movq %rsp, %rsi
movq %rax, %rdx
leaq 0x68(%rsp), %rcx
callq *0x28(%r8)
cmpb $0x1, 0x70db(%rip)      # 0xc253
jne 0x52d7
movq %r15, %rbx
xorl %edi, %edi
callq 0x3230
movq %rax, %rbp
movq 0x6e36(%rip), %rdi      # 0xbfc8
movq %r12, %r14
movq %r12, %rsi
callq 0x3240
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2fef(%rip), %rsi      # 0x819e
callq 0x32a0
leaq 0x68(%rsp), %rdi
callq 0x5ace
cltq
movq %r14, %rsi
subq %rax, %rsi
incq %rsi
movq %r15, %rdi
callq 0x3240
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2fbb(%rip), %rsi      # 0x819e
callq 0x32a0
movl %ebp, %r15d
subl %ebx, %r15d
movq %r12, %rdi
movl %r15d, %esi
callq 0x33d0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2f93(%rip), %rsi      # 0x819e
callq 0x32a0
movq %r12, %rdi
movq %rbp, %rsi
callq 0x3240
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2f71(%rip), %rsi      # 0x819e
callq 0x32a0
movq %r14, %rax
subq %r13, %rax
cvtsi2sd %rax, %xmm0
cvtsi2sd %r15d, %xmm1
divsd %xmm1, %xmm0
movq %r12, %rdi
callq 0x3390
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq %rax, %rdi
callq 0x3180
leaq 0xd5(%rip), %rax        # 0x535c
movq %rax, 0xa0(%rsp)
movl $0x0, 0x128(%rsp)
movl $0xe, %edi
leaq 0xa0(%rsp), %rsi
xorl %edx, %edx
callq 0x3310
movb $0x0, 0x6f9e(%rip)      # 0xc253
movl $0xa, %edi
callq 0x3420
movq %rbp, %r15
movq %r14, %r12
movq %r14, %r13
leaq 0x10(%rsp), %rbp
movq 0x20(%rsp), %rbx
leaq 0x28(%rsp), %r14
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x52ed
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
incq %r12
jmp 0x5137
jmp 0x531e
jmp 0x531e
movq %rax, %rbx
jmp 0x5306
movq %rax, %rbx
leaq 0x10(%rsp), %rbp
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x5321
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x5321
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x661a
jmp 0x5330
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x6374
jmp 0x533f
movq %rax, %rbx
leaq 0x68ea(%rip), %rax      # 0xbc30
leaq 0x78(%rsp), %rdi
movq %rax, -0x10(%rdi)
callq 0x32c0
movq %rbx, %rdi
callq 0x33e0