Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can command line utilities be faster than C++? [closed]

Tags:

c++

grep

bash

sed

I have a project where I want to manipulate certain output files.

This can be accomplished using a combination of grep and sed and piping with |

Alternatively, I can also write a C++ program to do the same thing.

Is there a conclusive answer on which method will be faster since grep and sed should already be fairly well optimised?

like image 555
user788171 Avatar asked Jul 06 '11 21:07

user788171


People also ask

Is CLI faster?

It generally uses a mouse to execute commands. The speed of GUI is Slower than CLI. Because the keyboard is used to execute the commands, the speed of the CLI is Faster than GUI.

Why CMD is faster than GUI?

CLI - Command line users only need to utilize a keyboard to navigate the interface, often resulting in faster performance. GUI - While modern GUIs are fast and efficient, they require a mouse, so you must move your hand from the mouse to the keyboard to type.

Is terminal faster than GUI?

CLI is faster than GUI. The speed of GUI is slower than CLI. 5. CLI operating system needs only a keyboard.

Why is command line so fast?

Because it runs at terminal velocity.


2 Answers

From a technical standpoint, a well-written self-contained C++ program that does everything you need will be faster than using two (or more) shell commands interconnected with a pipe, simply because there will be no IPC overhead, and they can be tailor-made and optimized for your exact needs.

But unless you're writing a program that will be run 24/7 for years, you'll never notice enough gain to be worth the effort.

And the standard rules for pre-optimization apply...

like image 172
Flimzy Avatar answered Oct 18 '22 21:10

Flimzy


If I were you, use what is already out there as these have likely been around a long time and have been tested and tried. Writing a new program yourself to do the same thing seems like a reinventing the wheel type action and is prone to error.

like image 4
Tony The Lion Avatar answered Oct 18 '22 21:10

Tony The Lion