I found emacs terminal emulator (M-x term) to be very convenient. However, it is essential for me to time certain portions of my code accurately (in order to compare speed of different algorithms fairly).

To make sure that my speed measurements are unaffected, I have tried comparing the speed of the code using regular Ubuntu terminal (whatever shows up when I type "Terminal") and emacs terminal emulator and they seemed to be pretty close. However, when I started outputting things on the screen in large amounts, the emacs terminal emulator seemed MUCH slower.

I'm an emacs newbie, so I was wondering if somebody could confirm if my observation is correct: Speed of the actual computations is unaffected by using emacs terminal emulator, while the printout to screen is slowed down. Perhaps, if you know of something else that could be slow on the emacs terminal emulator, advice would be much appreciated.

  • 1
    Anything that has to be interpreted on the Emacs side is very likely to be slower than a purpose-built native application like xterm or gnome-terminal. There is little difference in the computation time because both the Emacs and the native terminal emulators run your programs as subprocesses. Handling process output, i.e. printing text to screen, scrolling the output buffer, etc., however, is likely to be much more optimised in an actual terminal emulator than in an emulator of an emulator running in an emulator which is a text editor. – Basil Jan 13 '18 at 18:53
  • More seriously though, Emacs will probably be slightly slower in terms of invocation latency (the time between your running the command and the program actually starting) as well, but this latency should be completely dwarfed by the overhead of handling process output. As always, you should profile to be absolutely sure, though. :) – Basil Jan 13 '18 at 18:58
  • I see! Thank you! Probably I will use the regular terminal for the actual timing just to be safe and keep the emacs just for preliminary tests! – Фадиме Бекмамбетова Jan 13 '18 at 18:59
  • If you're generating a lot of output, and writing it faster that the terminal can read it, then blocking i/o may cause your program to take more real time to complete than it would have done otherwise. Emacs term will process input slower than most terminals, so this could well be a factor for you. If your timing data is part of the output, you might write that to a different file handle, and redirect everything else to /dev/null – phils Feb 13 '18 at 2:04

You should be measuring the time taken to execute the computations you care about, not the time taken to print things to the terminal. Different terminal emulators vary in speed by an order of magnitude, if not more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.