LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-27-2017, 02:40 PM   #16
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,752
Blog Entries: 4

Rep: Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970

Here is an unscientific test. Ignore the 'real' times and notice the 'user' and 'sys' times for perl versus sed, for as similar usage as I could think of. For more complex tasks, it will be a different matter:

Code:
$ uname -sm
Linux armv7l

$ strings /dev/urandom | dd bs=1M count=1 > x
0+1 records in
0+1 records out
4096 bytes (4.1 kB) copied, 0.0881956 s, 46.4 kB/s

$ time for i in $(seq 1 100000); do sed -e 's/a/A/g; s/b/B/g; s/c/C/g; s/d/D/g; s/e/E/g; s/f/F/g; s/g/G/g; s/h/H/g; s/i/I/g; s/j/J/g; s/k/K/g; s/l/L/g; s/m/M/g; s/n/N/g; s/o/O/g; s/p/P/g; s/q/Q/g; s/r/R/g; s/s/S/g; s/t/T/g; s/u/U/g; s/v/V/g; s/w/W/g; s/x/X/g; s/y/Y/g; s/z/Z/g;' x > /dev/null; done

real    70m38.797s
user    48m37.344s
sys     17m12.916s

$ time for i in $(seq 1 100000); do sed -e 's/a/A/g; s/b/B/g; s/c/C/g; s/d/D/g; s/e/E/g; s/f/F/g; s/g/G/g; s/h/H/g; s/i/I/g; s/j/J/g; s/k/K/g; s/l/L/g; s/m/M/g; s/n/N/g; s/o/O/g; s/p/P/g; s/q/Q/g; s/r/R/g; s/s/S/g; s/t/T/g; s/u/U/g; s/v/V/g; s/w/W/g; s/x/X/g; s/y/Y/g; s/z/Z/g;' x > /dev/null; done

real    71m36.424s
user    48m35.768s
sys     17m34.976s

$ time for i in $(seq 1 100000); do perl -e 's/a/A/g; s/b/B/g; s/c/C/g; s/d/D/g; s/e/E/g; s/f/F/g; s/g/G/g; s/h/H/g; s/i/I/g; s/j/J/g; s/k/K/g; s/l/L/g; s/m/M/g; s/n/N/g; s/o/O/g; s/p/P/g; s/q/Q/g; s/r/R/g; s/s/S/g; s/t/T/g; s/u/U/g; s/v/V/g; s/w/W/g; s/x/X/g; s/y/Y/g; s/z/Z/g;' x > /dev/null; done

real    43m40.400s
user    17m26.624s
sys     22m18.952s

$ time for i in $(seq 1 100000); do perl -e 's/a/A/g; s/b/B/g; s/c/C/g; s/d/D/g; s/e/E/g; s/f/F/g; s/g/G/g; s/h/H/g; s/i/I/g; s/j/J/g; s/k/K/g; s/l/L/g; s/m/M/g; s/n/N/g; s/o/O/g; s/p/P/g; s/q/Q/g; s/r/R/g; s/s/S/g; s/t/T/g; s/u/U/g; s/v/V/g; s/w/W/g; s/x/X/g; s/y/Y/g; s/z/Z/g;' x > /dev/null; done

real    43m48.563s
user    17m25.500s
sys     22m22.020s
 
2 members found this post helpful.
Old 04-27-2017, 04:10 PM   #17
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Rep: Reputation: 143Reputation: 143
Quote:
Originally Posted by Turbocapitalist View Post
Here is an unscientific test. Ignore the 'real' times and notice the 'user' and 'sys' times for perl versus sed, for as similar usage as I could think of. For more complex tasks, it will be a different matter:
Very interesting. The much lower user time for perl confirms that it is much better at regular expressions than sed.

But, to be more accurate, you'd have to call sed for every regular expression like this:

Code:
$ time for i in $(seq 1 100000); do 
  sed -e 's/a/A/g;' x > /dev/null
   sed -e 's/b/B/g;'  x > /dev/null
   sed -e 's/c/C/g;' x > /dev/null
    sed -e ' s/d/D/g;' x > /dev/null
     sed -e 's/e/E/g;' x > /dev/null
     sed -e 's/f/F/g;'  x > /dev/null
   sed -e 's/g/G/g;' x > /dev/null
   sed -e 's/h/H/g;' x > /dev/null
    sed -e 's/i/I/g;' x > /dev/null
    sed -e 's/j/J/g;' x > /dev/null
    sed -e 's/k/K/g;' x > /dev/null
    sed -e 's/l/L/g;' x > /dev/null
     sed -e 's/m/M/g;'  x > /dev/null
     sed -e 's/n/N/g;' x > /dev/null
     sed -e 's/o/O/g;' x > /dev/null
     sed -e 's/p/P/g;' x > /dev/null
     sed -e 's/q/Q/g;' x > /dev/null
     sed -e ' s/r/R/g;' x > /dev/null
     sed -e 's/s/S/g;'  x > /dev/null
     sed -e 's/t/T/g;'  x > /dev/null
     sed -e 's/u/U/g;'  x > /dev/null
     sed -e 's/v/V/g;'  x > /dev/null
     sed -e 's/w/W/g;'  x > /dev/null
     sed -e 's/x/X/g;'  x > /dev/null
     sed -e 's/y/Y/g;'  x > /dev/null
     sed -e 's/z/Z/g;' x > /dev/null
 done
That would surely raise your sys time dramatically.
 
Old 04-27-2017, 05:59 PM   #18
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,385

Rep: Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191
No, the test structure is valid - see post #3, the OP accepted the correction.

I certainly wasn't expecting that. Some subset testing of Turbocapitalist benchmark on x86_64 showed completely different results. In fact they came within 1% of each other, perl generally taking fractionally longer real time ...
If I get bored on the weekend I might set up some kernel tracing.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Issue: Bash script displays its name upon execution gacanepa Linux - Newbie 8 07-08-2013 02:17 PM
Bash script execution dann_radkov Linux - Newbie 5 10-18-2011 09:46 AM
[SOLVED] Bash script execution error dann_radkov Linux - Newbie 4 09-13-2011 03:15 PM
Detect bash script source vs. direct execution Jessard Programming 11 11-30-2010 06:43 AM
BASH: open console on script execution Quis Programming 2 02-07-2006 09:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration