// File: /workspace/github_cpp_makefile_star2_O1/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 0x5910
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 0x62b8
leaq 0x48(%rsp), %rdi
movl $0x14, %esi
movl $0x9c40, %edx           # imm = 0x9C40
movl $0xea60, %ecx           # imm = 0xEA60
callq 0x64e4
leaq 0x2e1(%rip), %rax       # 0x5382
leaq 0xa0(%rsp), %rsi
movq %rax, (%rsi)
movl $0x0, 0x88(%rsi)
movl $0xe, %edi
xorl %edx, %edx
callq 0x3310
movb $0x0, 0x818a(%rip)      # 0xd253
movl $0xa, %edi
callq 0x3420
movq 0x7eee(%rip), %rdi      # 0xcfc8
leaq 0x408c(%rip), %rsi      # 0x916d
movl $0xf, %edx
callq 0x32a0
movq 0x7ed6(%rip), %rdi      # 0xcfc8
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 0x7e9d(%rip), %rdi      # 0xcfc8
leaq 0x404b(%rip), %rsi      # 0x917d
movl $0x20, %edx
callq 0x32a0
movq 0x7e85(%rip), %rdi      # 0xcfc8
callq 0x30f0
leaq 0x10(%rsp), %rbp
xorl %r13d, %r13d
leaq 0x28(%rsp), %r14
xorl %r12d, %r12d
movq %rbx, 0x20(%rsp)
movq %r14, %rdi
callq 0x6412
movq %rsp, %rdi
movq %rax, %rsi
leaq 0xa0(%rsp), %rdx
callq 0x3e5a
leaq 0x48(%rsp), %rdi
callq 0x66b0
movq (%rbx), %r8
movq %rbx, %rdi
movq %rsp, %rsi
movq %rax, %rdx
leaq 0x68(%rsp), %rcx
callq *0x28(%r8)
cmpb $0x1, 0x80b5(%rip)      # 0xd253
jne 0x52fd
movq %r15, %rbx
xorl %edi, %edi
callq 0x3230
movq %rax, %rbp
movq 0x7e10(%rip), %rdi      # 0xcfc8
movq %r12, %r14
movq %r12, %rsi
callq 0x3240
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3fc9(%rip), %rsi      # 0x919e
callq 0x32a0
leaq 0x68(%rsp), %rdi
callq 0x5b0c
cltq
movq %r14, %rsi
subq %rax, %rsi
incq %rsi
movq %r15, %rdi
callq 0x3240
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3f95(%rip), %rsi      # 0x919e
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 0x3f6d(%rip), %rsi      # 0x919e
callq 0x32a0
movq %r12, %rdi
movq %rbp, %rsi
callq 0x3240
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3f4b(%rip), %rsi      # 0x919e
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        # 0x5382
movq %rax, 0xa0(%rsp)
movl $0x0, 0x128(%rsp)
movl $0xe, %edi
leaq 0xa0(%rsp), %rsi
xorl %edx, %edx
callq 0x3310
movb $0x0, 0x7f78(%rip)      # 0xd253
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 0x5313
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
incq %r12
jmp 0x515d
jmp 0x5344
jmp 0x5344
movq %rax, %rbx
jmp 0x532c
movq %rax, %rbx
leaq 0x10(%rsp), %rbp
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x5347
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x5347
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x666e
jmp 0x5356
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x63d0
jmp 0x5365
movq %rax, %rbx
leaq 0x78c4(%rip), %rax      # 0xcc30
leaq 0x78(%rsp), %rdi
movq %rax, -0x10(%rdi)
callq 0x32c0
movq %rbx, %rdi
callq 0x33e0