News for hackers. Stuff that matters.
Re:Node.js 13.0 by simplyinfinity on Tuesday October 22, 2019 @04:36PM (#21328245)

  console:
  The output console.timeEnd()
  and console.timeLog() 
  will now automatically select a suitable time unit instead of always using milliseconds (Xavier Stouder) #29251
Am I the only one that finds this unacceptable? Instead of a consistent result of a number, let's return string.. That now I have to parse..
Re:Node.js 13.0 by emilsedgh on Tuesday October 22, 2019 @04:51PM (#21328383)
I believe it rever really returned anything. It just wrote them on stdout.

It's not an API incompatibility.

Re:Node.js 13.0 by bilalq on Tuesday October 22, 2019 @04:57PM (#21328437)
It is a shift in the behavior of a side-effect though. Anyone who set up metric math based on log values here would be in for a surprise when they try to look at their reports.

This is definitely one of the gray areas when deciding whether or not to consider it a breaking change.

Re:Node.js 13.0 by playpause on Wednesday October 23, 2019 @03:47AM (#21332196)
I agree it’s grey-area, but I’d lean towards calling it a breaking change, as it’s not too hard to imagine setups that would rely on a particular stdout format (e.g. some kind of log-parsing to generate an HTML report from an e2e test orchestration suite). But this is a major update, so breaking is fine anyway.
Re:Node.js 13.0 by dickeytk on Tuesday October 22, 2019 @04:42PM (#21328304)
I think it’s ok, it’s just a debug statement that I think outputs to stderr. You should never be parsing it.
Re:Node.js 13.0 by simplyinfinity on Tuesday October 22, 2019 @04:46PM (#21328339)
Shouldn't it be better to have a second function that spits out a formatted version? Or a parameter for a format. Or a parameter to switch between pretty and raw numbers?
Re:Node.js 13.0 by dickeytk on Tuesday October 22, 2019 @04:58PM (#21328457)
no—this is something that likely shouldn't ever even be committed into a codebase. It's just something you throw in while testing to check why the performance of something is acting up.

The default is really important for something like this. Much more important than consistency.

Re:Node.js 13.0 by snek on Tuesday October 22, 2019 @05:28PM (#21328663)
You should not parse the stdout produced from console functions. It is for producing human-readable information. If you want machine-consumable data, you should use something like benchmark.js.
Re:Node.js 13.0 by BillinghamJ on Thursday October 24, 2019 @03:30AM (#21342463)
That's true of stderr output. You should be able to parse stdout though - otherwise how are you meant to use piping etc
Re:Node.js 13.0 by nothrabannosir on Tuesday October 22, 2019 @07:15PM (#21329431)
How far we have strayed from the days where Unix tools were meant to be used as a stdlib, called through stdin and out. It makes me a little sad.

Classic HN comment on this topic: https://news.ycombinator.com/item?id=6530180

Re:Node.js 13.0 by snek on Tuesday October 22, 2019 @11:44PM (#21330860)
Not that far. Node has process.stdout/process.stdin/process.stderr. It's just that the console API is for debugging.
Re:Node.js 13.0 by Dashron on Tuesday October 22, 2019 @04:48PM (#21328356)
I looked at the code (but didnt try it) and I think this only affects console output, not any return value that you would parse.
Re:Node.js 13.0 by CryoLogic on Tuesday October 22, 2019 @04:39PM (#21328278)
Agreed. That's a ridiculous change.

A well defined function should have a single purpose, and a reliable and repeatable output.

Re:Node.js 13.0 by _bxg1 on Tuesday October 22, 2019 @04:51PM (#21328378)
It doesn't output back into your code though; it goes directly to stdout, so its main priority is readability for debugging. If you need log-quality output for parsing by another program there are plenty of libraries for getting time in whatever format you wish.
Re:Node.js 13.0 by avarun on Tuesday October 22, 2019 @04:47PM (#21328343)
It's a function on `console`. It's meant to be human-readable, not machine-readable.
Re:Node.js 13.0 by sundvor on Tuesday October 22, 2019 @06:21PM (#21329041)
Console logging can be useful for eg being fed into Splunk from an ECS instance.

I don't do node.js so perhaps there are other ways of doing that specifically. (Works great in .net core)