Skip to content
Snippets Groups Projects
Commit 79dc0fa4 authored by Jake Read's avatar Jake Read
Browse files

prep for ops reduction

parent 3b263fb6
Branches
No related tags found
No related merge requests found
......@@ -39,6 +39,8 @@ function Logger() {
let val = tolog.get()
if(Array.isArray(val)){
val = val.join(', ')
} else if (typeof val === "boolean"){
val = val.toString()
}
$(this.dom).children('.txt').html(val)
if (logToConsole.value === true) {
......
/*
the graph, it's shaped like a V
*/
import {
Hunkify,
Input,
Output,
State
} from '../hunks.js'
function Timing(){
Hunkify(this)
let inp = new Input('boolean', 'thru', this)
this.inputs.push(inp)
let out = new Output('boolean', 'thru', this)
this.outputs.push(out)
let count = new State('number', 'average', 100)
this.states.push(count)
let val = false
let t0 = performance.now()
let t1 = t0
let avsum = 0
let avcnt = 0
this.loop = () => {
if(inp.io && !(out.io)){
// through the gate
out.put(inp.get())
// new value
t1 = performance.now()
// work
avsum += t1 - t0
t0 = t1
avcnt ++
if(avcnt > count.value){
console.log("tm: ", avsum / count.value)
avcnt = 0
avsum = 0
}
}
}
}
export default Timing
{
"interpreterName": "cuttlefish",
"interpreterVersion": "v0.1",
"hunks": [
{
"type": "manager",
"name": "nrol",
"inputs": [
{
"name": "msgs",
"type": "byteArray"
}
],
"outputs": [
{
"name": "msgs",
"type": "byteArray",
"connections": [
{
"inHunkIndex": 1,
"inHunkInput": 0
}
]
}
],
"states": []
},
{
"type": "view",
"name": "tlview",
"inputs": [
{
"name": "msgs",
"type": "byteArray"
}
],
"outputs": [
{
"name": "msgs",
"type": "byteArray",
"connections": [
{
"inHunkIndex": 0,
"inHunkInput": 0
}
]
}
],
"states": []
},
{
"type": "debug/timing",
"name": "debug/timing_2",
"inputs": [
{
"name": "thru",
"type": "boolean"
}
],
"outputs": [
{
"name": "thru",
"type": "boolean",
"connections": [
{
"inHunkIndex": 4,
"inHunkInput": 0
}
]
}
],
"states": [
{
"name": "average",
"type": "number",
"value": 100
}
]
},
{
"type": "interface/button",
"name": "interface/button_3",
"inputs": [
{
"name": "trigger",
"type": "any"
}
],
"outputs": [
{
"name": "onclick",
"type": "boolean",
"connections": [
{
"inHunkIndex": 4,
"inHunkInput": 0
}
]
}
],
"states": []
},
{
"type": "math/booleaninversion",
"name": "math/booleaninversion_4",
"inputs": [
{
"name": "state",
"type": "boolean"
}
],
"outputs": [
{
"name": "inverted",
"type": "boolean",
"connections": [
{
"inHunkIndex": 2,
"inHunkInput": 0
}
]
}
],
"states": []
}
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment