2015-10-02 14:29:15 +02:00
|
|
|
#include <benchmark/benchmark.h>
|
2015-04-13 10:18:58 +02:00
|
|
|
|
2015-10-02 14:06:21 +02:00
|
|
|
#include "mstch/mstch.hpp"
|
2015-04-13 10:18:58 +02:00
|
|
|
|
2015-10-02 14:29:15 +02:00
|
|
|
static void basic_usage(benchmark::State& state) {
|
2015-10-02 14:06:21 +02:00
|
|
|
std::string comment_tmp{
|
|
|
|
"<div class=\"comments\"><h3>{{header}}</h3><ul>"
|
|
|
|
"{{#comments}}<li class=\"comment\"><h5>{{name}}</h5>"
|
|
|
|
"<p>{{body}}</p></li>{{/comments}}</ul></div>"};
|
|
|
|
|
|
|
|
auto comment_view = mstch::map{
|
|
|
|
{"header", std::string{"My Post Comments"}},
|
|
|
|
{"comments", mstch::array{
|
|
|
|
mstch::map{{"name", std::string{"Joe"}}, {"body", std::string{"Thanks for this post!"}}},
|
|
|
|
mstch::map{{"name", std::string{"Sam"}}, {"body", std::string{"Thanks for this post!"}}},
|
|
|
|
mstch::map{{"name", std::string{"Heather"}}, {"body", std::string{"Thanks for this post!"}}},
|
|
|
|
mstch::map{{"name", std::string{"Kathy"}}, {"body", std::string{"Thanks for this post!"}}},
|
|
|
|
mstch::map{{"name", std::string{"George"}}, {"body", std::string{"Thanks for this post!"}}}}}};
|
|
|
|
|
2015-10-02 14:29:15 +02:00
|
|
|
while (state.KeepRunning())
|
2015-10-02 14:06:21 +02:00
|
|
|
mstch::render(comment_tmp, comment_view);
|
2015-10-02 14:29:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK(basic_usage);
|
|
|
|
|
|
|
|
BENCHMARK_MAIN();
|