Is BASH very slow?

后端 未结 4 1855
时光取名叫无心
时光取名叫无心 2021-01-18 03:14

I was solving this question on SPOJ - http://www.spoj.com/problems/ALICESIE/

What the question boils down to print (n+1)/2

This is my C code which passes in

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-18 04:05

    You're comparing compiled code with a script language (Bash).

    Bash scripts will always be slower than compiled code as they need to be interpreted.

    As you probably know, in order to run your code written in C you first need to compile it. When it comes to Bash scripts, you don't have to read it, the code is just "read on the fly". So Bash is slower than C.

提交回复
热议问题