Re: cpuTime not in JS backend?

2018-03-20 Thread treeform
Also DOM package does not include performance.now which requires and {.emit.} 
to get working.


Re: cpuTime not in JS backend?

2018-03-19 Thread GULPF
> In some old version of times.nim cpuTime was mapped to epochTime if the 
> platform would not support cpuTime. I think we can do that again; best effort 
> approximations for the JS target are a fact of life.

I disagree. The whole point of a monotonic clock is that it's guaranteed to be 
monotonic. A non-monotonic clock should not be used as a approximation. If 
`cpuTime` has to work in the browser (and I don't think it has to if the 
`times` module gets a proper monotonic time type) it should use 
`performance.now`. If the user decides that a non-monotonic clock is an 
acceptable fallback for their use case they can use a shim for 
`performance.now`.


Re: cpuTime not in JS backend?

2018-03-19 Thread Araq
In some old version of `times.nim` `cpuTime` was mapped to `epochTime` if the 
platform would not support `cpuTime`. I think we can do that again; best effort 
approximations for the JS target are a fact of life.


Re: cpuTime not in JS backend?

2018-03-19 Thread GULPF
`cpuTime` is not supported for the JS backend, because there is no way to get 
the CPU time from the browser. I suppose it would be possible to implement it 
for Nodejs though. Your best bet for measuring time in the browser is to wrap 
[performance.now](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now),
 or to use `times.epochTime` (which is not monotonic). I plan to add a proper 
monotonic time type to the `times` module (which will use `performance.now` for 
the JS backend) after my nanosecond resolution PR has been merged.


cpuTime not in JS backend?

2018-03-19 Thread sdwfrost
Dear All,

In compiling my Nim code 
[here](https://gist.github.com/sdwfrost/7c660322c6c33961297a826df4cbc30d) using 
the Javascript backend, I got an error message:


nim js -d:release -o:sir_opt.js  sir_opt
sir_opt.nim(55, 12) Error: undeclared identifier: 'cpuTime'


Is cpuTime not defined within the times package (which in the docs, says it is 
compatible with JS)?

Best wishes

Simon