update readme
This commit is contained in:
parent
55c49e5ce1
commit
c4b5eb8664
@ -14,10 +14,10 @@ int main() {
|
|||||||
std::string view{"{{#names}}Hi {{name}}!\n{{/names}}"};
|
std::string view{"{{#names}}Hi {{name}}!\n{{/names}}"};
|
||||||
mstch::map context{
|
mstch::map context{
|
||||||
{"names", mstch::array{
|
{"names", mstch::array{
|
||||||
mstch::map{{"name", std::string{"Chris"}},
|
mstch::map{{"name", std::string{"Chris"}}},
|
||||||
mstch::map{{"name", std::string{"Mark"}},
|
mstch::map{{"name", std::string{"Mark"}}},
|
||||||
mstch::map{{"name", std::string{"Scott"}},
|
mstch::map{{"name", std::string{"Scott"}}},
|
||||||
}
|
}}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::cout << mstch::render(view, context) << std::endl;
|
std::cout << mstch::render(view, context) << std::endl;
|
||||||
|
@ -1,42 +1,18 @@
|
|||||||
#include "mstch/mstch.hpp"
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
unsigned long current_msec() {
|
#include <mstch/mstch.hpp>
|
||||||
return std::chrono::system_clock::now().time_since_epoch() /
|
|
||||||
std::chrono::milliseconds(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::string comment_tmp{
|
std::string view{"{{#names}}Hi {{name}}!\n{{/names}}"};
|
||||||
"<div class=\"comments\"><h3>{{header}}</h3><ul>"
|
mstch::map context{
|
||||||
"{{#comments}}<li class=\"comment\"><h5>{{name}}</h5>"
|
{"names", mstch::array{
|
||||||
"<p>{{body}}</p></li>{{/comments}}</ul></div>"};
|
mstch::map{{"name", std::string{"Chris"}}},
|
||||||
|
mstch::map{{"name", std::string{"Mark"}}},
|
||||||
|
mstch::map{{"name", std::string{"Scott"}}},
|
||||||
|
}}
|
||||||
|
};
|
||||||
|
|
||||||
auto comment_view = mstch::map{
|
std::cout << mstch::render(view, context) << std::endl;
|
||||||
{"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::vector<unsigned long> times;
|
return 0;
|
||||||
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;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user