Skip to content

Commit

Permalink
feat: add perf example
Browse files Browse the repository at this point in the history
  • Loading branch information
eliassjogreen committed Dec 5, 2020
1 parent 8114c4c commit 9b852cd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions denon.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
"cmd": "deno run scripts/dev.ts examples/multiple.ts",
"desc": "run `multiple` example"
},
"dev:perf": {
"cmd": "deno run scripts/dev.ts examples/perf.ts",
"desc": "run `perf` example"
},
"dev:remote": {
"cmd": "deno run scripts/dev.ts examples/remote.ts",
"desc": "run `remote` example"
Expand Down
28 changes: 28 additions & 0 deletions examples/perf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Webview } from "../mod.ts";

const html = `
<html>
<body>
<button onclick="external.invoke('test')">test</button>
<script>
function test() { external.invoke("finish"); }
</script>
</body>
</html>
`;

const webview = new Webview(
{ url: `data:text/html,${encodeURIComponent(html)}` },
);

await webview.run((event) => {
switch(event) {
case "test":
console.time();
webview.eval("test();");
break;
case "finish":
console.timeEnd();
break;
}
});

0 comments on commit 9b852cd

Please sign in to comment.