From c4b5eb8664c6a9508cf30a261685437ba37a8629 Mon Sep 17 00:00:00 2001 From: Daniel Sipka Date: Fri, 24 Apr 2015 01:37:09 +0200 Subject: [PATCH] update readme --- README.md | 8 +++---- test/benchmark_main.cpp | 48 +++++++++++------------------------------ 2 files changed, 16 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index a98bf5d..326554f 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,10 @@ int main() { std::string view{"{{#names}}Hi {{name}}!\n{{/names}}"}; mstch::map context{ {"names", mstch::array{ - mstch::map{{"name", std::string{"Chris"}}, - mstch::map{{"name", std::string{"Mark"}}, - mstch::map{{"name", std::string{"Scott"}}, - } + mstch::map{{"name", std::string{"Chris"}}}, + mstch::map{{"name", std::string{"Mark"}}}, + mstch::map{{"name", std::string{"Scott"}}}, + }} }; std::cout << mstch::render(view, context) << std::endl; diff --git a/test/benchmark_main.cpp b/test/benchmark_main.cpp index 412581b..550670d 100644 --- a/test/benchmark_main.cpp +++ b/test/benchmark_main.cpp @@ -1,42 +1,18 @@ -#include "mstch/mstch.hpp" - -#include #include -unsigned long current_msec() { - return std::chrono::system_clock::now().time_since_epoch() / - std::chrono::milliseconds(1); -} +#include int main() { - std::string comment_tmp{ - "

{{header}}

    " - "{{#comments}}
  • {{name}}
    " - "

    {{body}}

  • {{/comments}}
"}; + std::string view{"{{#names}}Hi {{name}}!\n{{/names}}"}; + mstch::map context{ + {"names", mstch::array{ + mstch::map{{"name", std::string{"Chris"}}}, + mstch::map{{"name", std::string{"Mark"}}}, + mstch::map{{"name", std::string{"Scott"}}}, + }} + }; - 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!"}}}}}}; + std::cout << mstch::render(view, context) << std::endl; - std::vector times; - for (int j = 0; j < 10; j++) { - unsigned long start = current_msec(); - for (int i = 0; i < 5000; i++) - mstch::render(comment_tmp, comment_view); - times.push_back(current_msec() - start); - } - - float avg = 0; - for (auto i: times) - avg += i; - avg /= times.size(); - - std::cout << avg << std::endl; - - return 0; -} + return 0; + } \ No newline at end of file