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

Evaluate the performance impact of cprintf #12

Open
dpo opened this issue Sep 14, 2017 · 3 comments
Open

Evaluate the performance impact of cprintf #12

dpo opened this issue Sep 14, 2017 · 3 comments

Comments

@dpo
Copy link
Member

dpo commented Sep 14, 2017

cprintf seems to be the only way to print colored strings in the command window. Some users report that it's slow. What is its performance impact exactly?

@schelian
Copy link

Just did a quick (& by no means exhaustive) test and it seems to add a second. Below are some timing result for calling disp vs cprintf 200 times; the test code is below it.

etime1 =

    0.0025


etime2 =

    1.1826


etime3 =

    1.1397
N = 200;

tic;
for i = 1:N
   disp( 'hi' );
end
etime1 = toc;

tic;
for i = 1:N
   cprintf( 'hi\n' );
end
etime2 = toc;

tic;
for i = 1:N
   cprintf( '*[1,0,0]', 'hi\n' );
end
etime3 = toc;

etime1
etime2
etime3

@dpo
Copy link
Member Author

dpo commented Feb 19, 2019

Well, does it add a second, or is it 473 times slower?

@schelian
Copy link

Yeah it's slower. If I increase N to 2000, I get the results below. Hopefully someone is doing much more computation than logging so an extra 10 seconds w/ cprintf would not be a bother. Perhaps cprintf can be an option?

etime1 =

    0.0176


etime2 =

   11.2543


etime3 =

   11.2563

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

No branches or pull requests

2 participants