|
- const cpp_code = `
- #include <cheerp/client.h>
- #include <cheerp/clientlib.h>
-
- class [[cheerp::jsexport]] JsBridge
- {
- public:
- JsBridge() = default;
- void test()
- {
- volatile size_t counter = 0;
- for (int i = 0; i < 100000; ++i) {
- for (int j = 0; j < 10000; ++j) {
- counter++;
- }
- }
- }
- };
- void webMain() {}
- `.trim();
-
- const html_code = `
- <html>
- <head>
- <script>
- function test() {
- counter = 0
- for (i = 0; i < 100000; ++i) {
- for (j = 0; j < 10000; ++j) {
- counter++;
- }
- }
- }
- setTimeout(function() {
- var jsBridge = new JsBridge();
- {
- var start = new Date().getTime();
- test();
- var time = new Date().getTime() - start;
- document.getElementById('output').innerHTML += "Javascript execution time:" + time + "<br>";
- }
-
- {
- var start = new Date().getTime();
- jsBridge.test();
- var time = new Date().getTime() - start;
- document.getElementById('output').innerHTML += "Compiled JS execution time:" + time + "<br>";
- }
- return false;
- }, 500);
- </script>
- </head>
- <body id="output">
- </body>
- </html>`.trim();
-
- const js_code = ``.trim();
-
- const flags = `
- -cheerp-pretty-code
- -cheerp-no-type-optimizer
- -cheerp-no-native-math
- -cheerp-no-math-imul
- -cheerp-no-math-fround
- -O3
- -target cheerp`.trim()
-
- const wasm_code = '';
-
- export const perf_example = { cpp: cpp_code, js: js_code, wasm: wasm_code, html: html_code, flags: flags }
|