Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-nadymov committed Jul 19, 2019
1 parent 74c0aa7 commit 10e7d7b
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 41 deletions.
149 changes: 149 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"homepage": "https://evgeny-nadymov.github.io/wasm-caching",
"name": "wasm-caching",
"version": "0.1.0",
"private": true,
Expand All @@ -12,7 +13,9 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -28,5 +31,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"gh-pages": "^2.0.1"
}
}
70 changes: 30 additions & 40 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,46 @@ import './App.css';

class App extends React.Component{

handleInstantiateFibonacchi = async event => {
handleCompileTdlib = async event => {
event.preventDefault();

const fetchPromise = fetch('fibonacci.wasm');
const { instance } = await WebAssembly.instantiateStreaming(fetchPromise);
const result = instance.exports.fibonacci(42);
console.log(result);
console.log('compileStreaming start');
const t0 = performance.now();
const fetchPromise = fetch('ef5b7375afcb3e32ba4066a0003c699c.wasm');
const module = await WebAssembly.compileStreaming(fetchPromise);
console.log('compileStreaming finish time=' + (performance.now() - t0));
};

handleInstantiateTdlib = async event => {
event.preventDefault();

const fetchPromise = fetch('ef5b7375afcb3e32ba4066a0003c699c.wasm');
const module = await WebAssembly.compileStreaming(fetchPromise);
console.log(module);
console.log('start tdlib');
let options = {
logVerbosityLevel: 1,
jsLogVerbosityLevel: 3,
mode: 'wasm',
prefix: 'tdlib',
readOnly: false,
isBackground: false,
useDatabase: false
};

this.client = new TdClient(options);
this.client.onUpdate = update => {

// let options = {
// logVerbosityLevel: 1,
// jsLogVerbosityLevel: 3,
// mode: 'wasm',
// prefix: 'tdlib',
// readOnly: false,
// isBackground: false,
// useDatabase: false
// };
//
// this.client = new TdClient(options);
// this.client.onUpdate = update => {
//
// };
};
};

generateBigWasm = async event => {
// event.preventDefault();
handleInstantiateFibonacchi = async event => {
event.preventDefault();

// let str = '';
// for (let i = 0; i < 1000; i++) {
// str += `
//
// WASM_EXPORT
// int fibonacci${i}(int n) {
// int i, t, a = 0, b = 1;
// for (i = 0; i < n; i++) {
// t = a + b;
// a = b;
// b = t;
// }
// return b;
// }`;
// }
// console.log(str);
console.log('instantiateStreaming start');
const t0 = performance.now();
const fetchPromise = fetch('fibonacci.wasm');
const { instance } = await WebAssembly.instantiateStreaming(fetchPromise);
console.log('instantiateStreaming finish time=' + (performance.now() - t0));
const result = instance.exports.fibonacci(42);
console.log(result);
};

render() {
Expand All @@ -67,6 +56,7 @@ class App extends React.Component{
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<button onClick={this.handleCompileTdlib}>compile tdlib</button>
<button onClick={this.handleInstantiateTdlib}>instantiate tdlib</button>
<button onClick={this.handleInstantiateFibonacchi}>instantiate fib</button>
</header>
Expand Down

0 comments on commit 10e7d7b

Please sign in to comment.