Hacker News new | past | comments | ask | show | jobs | submit login

So, doing another simple change to my code brought the runtime down to a few ms. Doing:

  time yes | head -n1000000 | perl6 --profile -e 'for $*IN.readchars { .subst("y", "n").print }’ > /dev/null
says it took 86 ms. Which is pretty decent I’d say.



Sure, but that's still kinda defeating the purpose of providing functionality that's easy to remember and type. Might as well do

  time echo "#include <stdio.h>
  main(n){char*b,*s=n=0;getdelim(&s,&n,-1,stdin);for(b=s;*s;++s)*s=='y'&&*s='n';puts(b);}">s.c|yes|head -n1000000|tcc -w -run s.c>/dev/null

  real	0m0.028s
  user	0m0.023s
  sys	0m0.019s
28 milliseconds!


I was mostly just pointing out that perl6 might not be as slow as the comment you linked suggests. There seems to be something about using `perl6 -pe` that caused it to be slower than you’d expected. However, using a different approach its reasonably fast, or at least it appears reasonably comparable to the perl 5 example that was provided.

Hopefully more edge cases will be discovered and fixed as the implementation matures as well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: