c42f / tinyformat

Minimal, type safe printf replacement library for C++
537 stars 75 forks source link

Speed tests: add test for largest data #22

Closed skynowa closed 9 years ago

skynowa commented 9 years ago
    #define str \
        "asdcf'awsrk.fw3[045im2,[4oc'wxe;/fzd1[-,c4rxj.wk;szlcgjx34-rx134rxqwetaertg" \
        "asdcf'awsrk.fw3[045im2,[4oc'wxe;/fzd1[-,c4rxj.wk;szlcgjx34-rx134rxqwetaertg" \
        "asdcf'awsrk.fw3[045im2,[4oc'wxe;/fzd1[-,c4rxj.wk;szlcgjx34-rx134rxqwetaertg" \
        "asdcf'awsrk.fw3[045im2,[4oc'wxe;/fzd1[-,c4rxj.wk;szlcgjx34-rx134rxqwetaertg" \
        "asdcf'awsrk.fw3[045im2,[4oc'wxe;/fzd1[-,c4rxj.wk;szlcgjx34-rx134rxqwetaertg" \
        "asdcf'awsrk.fw3[045im2,[4oc'wxe;/fzd1[-,c4rxj.wk;szlcgjx34-rx134rxqwetaertg" \
        "asdcf'awsrk.fw3[045im2,[4oc'wxe;/fzd1[-,c4rxj.wk;szlcgjx34-rx134rxqwetaertg" \
        "asdcf'awsrk.fw3[045im2,[4oc'wxe;/fzd1[-,c4rxj.wk;szlcgjx34-rx134rxqwetaertg" \
        "asdcf'awsrk.fw3[045im2,[4oc'wxe;/fzd1[-,c4rxj.wk;szlcgjx34-rx134rxqwetaertg" \
        "asdcf'awsrk.fw3[045im2,[4oc'wxe;/fzd1[-,c4rxj.wk;szlcgjx34-rx134rxqwetaertg"
...
    } else if (which == "tinyformat") {
        for (long i = 0; i < loops; ++ i) {
            tfm::printf("%0.10f" str "%04d" str "%+g" str "%s" str "%p" str "%c" str "%%\n",
                1.234, 42, 3.13, "string", (void *)1000, (int)'X');
        }
    }
...
c42f commented 9 years ago

That's certainly an odd value for str, is there any reasoning behind it?

skynowa commented 9 years ago

Soory. I mean, that add test for longest string. Instead "string" use str.

#define str "longest_string...................................................abc"

tfm::printf("%0.10f:%04d:%+g:%s:%p:%c:%%\n",
    1.234, 42, 3.13, str, (void *)1000, (int)'X');
c42f commented 9 years ago

Sorry for the delay, I forgot about this.

Your second example is testing something quite different from the first, so I'm still not quite sure what the intention is here.

Neither of these seem like particularly typical use cases, so I probably wouldn't put them in the main speed test - it is meant to be a simple "smoke test" to check that nothing has gone horribly wrong. However, if you'd care about performance, I'd encourage you to submit a pull request expanding the speed test into a full test suite with various different cases of interest. In that case I think it would make sense to compare against both libc printf and iostreams (boost::format is so far behind that we may as well ignore it)