Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random insertion of newline at end of process.stdout.write when NOT requested #1842

Closed
wolfsonga opened this issue Dec 19, 2013 · 1 comment

Comments

@wolfsonga
Copy link

Hi,
I posted this on Google Group but it may be a bug so I am posting it again here,
=Gerry=

Hi,

I am trying to use process.stdout.write to put a line to the console without generating a newline from Cloud9 on a Beaglebone Black. The reason I am doing this is that I am running a series of benchmarks and I want to put out a message ("benchmark #1 : ") to the console when I enter the benchmark function and then at the end of the benchmark function put out the number of milliseconds it took with the unit of measure ('235 ms\n') so that if I look at the console while I am running a series of benchmarks it would look like this:

benchmark took 19458 nanoseconds
benchmark took 19.458 microseconds
benchmark took 0.019458 milliseconds

Started of run =>

Speed test

The next tests are runtime compensated for overhead
hrtimeOverhead : 0.00000850540771 s
hrtimeOverhead : 0.00850540771 ms
hrtimeOverhead : 8.50540771 us
hrtimeOverhead : 8505.40771 ns

nop : 0.000030066145000000003 ms
digitalRead : 0.990526 ms
digitalWrite : 0.625301875 ms
pinMode : 0.1040031875 ms
multiply volatile byte : 0.000053372084999999996 ms
divide volatile byte : 0.000084959895 ms
multiply volatile integer : 0.0000576839575 ms
divide volatile integer : 0.000142190415 ms
multiply volatile long : 0.00005307218749999999 ms
multiply single float : 0.00005187062499999999 ms
multiply double float : 0.00005294 ms
divide double float : 0.000157255835 ms
random() : 0.0005705647900000001 ms
bitSet() with volatile : 0.00010729801999999999 ms
gmsleep(1) : 2.04154107325 ms
msleep(1) : 1.100040521 ms
msleep(100) : 100.2031421975 ms
delayMicroseconds(1) : 20.566331275000003 us
delayMicroseconds(5) : 18.272696875 us

delayMicroseconds(100) :141.256928125 us

Runtime = 71.811657967 seconds

<= End of run

However, as you can see below, some lines get put together correctly but others get a newline inserted before the second part is sent to the console. I am calling two functions to accomplish this from the benchmark function. One is "prnt" and the other is "prntln". The first does a process.stdout.write(passed_string_value); and the second does a process.stdout.write(passed_string_value + '\n');

benchmark took 19458 nanoseconds
benchmark took 19.458 microseconds
benchmark took 0.019458 milliseconds

Started of run =>

Speed test

The next tests are runtime compensated for overhead
hrtimeOverhead :
0.00000850540771 s
hrtimeOverhead : 0.00850540771 ms
hrtimeOverhead :
8.50540771 us
hrtimeOverhead : 8505.40771 ns
nop :
0.000030066145000000003 ms
digitalRead :
0.990526 ms
digitalWrite :
0.625301875 ms
pinMode :
0.1040031875 ms
multiply volatile byte :
0.000053372084999999996 ms
divide volatile byte :
0.000084959895 ms
multiply volatile integer :
0.0000576839575 ms
divide volatile integer :
0.000142190415 ms
multiply volatile long :
0.00005307218749999999 ms
multiply single float :
0.00005187062499999999 ms
multiply double float :
0.00005294 ms
divide double float :
0.000157255835 ms
random() :
0.0005705647900000001 ms
bitSet() with volatile :
0.00010729801999999999 ms
gmsleep(1) :
2.04154107325 ms
msleep(1) :
1.100040521 ms
msleep(100) :
100.2031421975 ms
delayMicroseconds(1) :
20.566331275000003 us
delayMicroseconds(5) :
18.272696875 us
delayMicroseconds(100) :

141.256928125 us

Runtime = 71.811657967 seconds

<= End of run

Am I doing something wrong or is there a bug or a buffer race condition I am not taking into account? Thanks for any insight you can give me,

=Gerrry=

@aheckmann
Copy link
Collaborator

wrong repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants