From d8250d5d7c9121aa4e4a4ed3b030106a37c0981b Mon Sep 17 00:00:00 2001 From: Luis Fraguada Date: Tue, 6 Oct 2020 16:03:18 +0200 Subject: [PATCH 1/9] sample warm up script --- example/warm.html | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 example/warm.html diff --git a/example/warm.html b/example/warm.html new file mode 100644 index 00000000..c89d661a --- /dev/null +++ b/example/warm.html @@ -0,0 +1,96 @@ + + + + + + + + Compute RestHopper Test + + + + + + + From eac7550a09e05561d94f292d1dfaceec10c1d6f0 Mon Sep 17 00:00:00 2001 From: Luis Fraguada Date: Tue, 6 Oct 2020 21:05:16 +0200 Subject: [PATCH 2/9] limit example sliders --- example/app.js | 3 +++ example/index.html | 4 ++-- routes/solve.js | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/example/app.js b/example/app.js index 1b14dbab..68272a22 100644 --- a/example/app.js +++ b/example/app.js @@ -30,6 +30,8 @@ async function compute(){ let t0 = performance.now() const timeComputeStart = t0 + console.log(data.inputs) + const request = { 'method':'POST', 'body': JSON.stringify(data), @@ -48,6 +50,7 @@ async function compute(){ { // hide spinner document.getElementById('loader').style.display = 'none' + console.log(responseJson) let data = JSON.parse(responseJson.values[0].InnerTree['{ 0; }'][0].data) let mesh = rhino.DracoCompression.decompressBase64String(data) diff --git a/example/index.html b/example/index.html index fe6fd3e0..716afe0d 100644 --- a/example/index.html +++ b/example/index.html @@ -42,11 +42,11 @@
- +
- +
diff --git a/routes/solve.js b/routes/solve.js index a05ee8a4..62be0904 100644 --- a/routes/solve.js +++ b/routes/solve.js @@ -71,11 +71,13 @@ function checkCache (req, res, next){ if(mc === null){ // use node cache + console.log('using node-cache') const result = cache.get(res.locals.cacheKey) res.locals.cacheResult = result !== undefined ? result : null next() } else { // use memcached + console.log('using memcached') if(mc !== null) { mc.get(res.locals.cacheKey, function(err, val) { if(err == null) { @@ -104,12 +106,14 @@ function commonSolve (req, res, next){ if(res.locals.cacheResult !== null) { //send + //console.log(res.locals.cacheResult) const timespanPost = Math.round(performance.now() - timePostStart) res.setHeader('Server-Timing', `cacheHit;dur=${timespanPost}`) res.send(res.locals.cacheResult) return } else { //solve + console.log('solving') // set parameters let trees = [] if(res.locals.params.inputs !== undefined) { //TODO: handle no inputs From c9d4c8c9516bc9d8ab3adbbc65663114a6ffa522 Mon Sep 17 00:00:00 2001 From: Luis Fraguada Date: Tue, 6 Oct 2020 22:19:01 +0200 Subject: [PATCH 3/9] Fixed issue with input value string --- example/app.js | 16 ++++++++-------- example/index.html | 4 ++-- example/warm.html | 18 ++++++++++++------ routes/solve.js | 11 +++++++---- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/example/app.js b/example/app.js index 68272a22..f12cf8da 100644 --- a/example/app.js +++ b/example/app.js @@ -2,9 +2,9 @@ let data = {} data.definition = 'BranchNodeRnd.gh' data.inputs = { - 'Length':document.getElementById('length').value, - 'Count':document.getElementById('count').value, - 'Radius':document.getElementById('radius').value + 'Count':document.getElementById('count').valueAsNumber, + 'Radius':document.getElementById('radius').valueAsNumber, + 'Length':document.getElementById('length').valueAsNumber } // set this to the target appserver url @@ -30,13 +30,13 @@ async function compute(){ let t0 = performance.now() const timeComputeStart = t0 - console.log(data.inputs) - const request = { 'method':'POST', 'body': JSON.stringify(data), 'headers': {'Content-Type': 'application/json'} } + + let response = await fetch(url, request) // Request finished. Do processing here. @@ -98,9 +98,9 @@ function onSliderChange () { // get slider values data.inputs = { - 'Length':document.getElementById('length').value, - 'Count':document.getElementById('count').value, - 'Radius':document.getElementById('radius').value + 'Count':document.getElementById('count').valueAsNumber, + 'Radius':document.getElementById('radius').valueAsNumber, + 'Length':document.getElementById('length').valueAsNumber } compute() } diff --git a/example/index.html b/example/index.html index 716afe0d..c44ddcf6 100644 --- a/example/index.html +++ b/example/index.html @@ -42,11 +42,11 @@
- +
- +
diff --git a/example/warm.html b/example/warm.html index c89d661a..69720af7 100644 --- a/example/warm.html +++ b/example/warm.html @@ -9,7 +9,7 @@ - +