Find the answer to your Linux question:
Results 1 to 6 of 6
I've been trying to use the time command to benchmark the speeds of LZMA, GZIP, and BZIP2. So far I've come up with this command: Code: for a in 100; ...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    4

    Using the Time command for Benchmarking

    I've been trying to use the time command to benchmark the speeds of LZMA, GZIP, and BZIP2.

    So far I've come up with this command:
    Code:
    for a in 100; do for b in "bzip2" "lzma" "gzip"; do dd if=/dev/zero of=$a.$b.zero bs=${a}M count=1; time $b $a.$b.zero > $a.$b | sed "s|.* [0-9\.]*s user [0-9\.]*s system [0-9]*% cpu \([0-9\.]*\) total|\1|" >> benchmark; echo -n "," >> benchmark; done; echo >> benchmark; done
    But the problem is, the Time command seems to be able to intercept my | between Time and Sed. I have the sed to write to a file that would have the data in it.

    Is there anyway I could make this work?


    Note: So eventually I want to be able to run:
    Code:
    gnuplot -persist <(echo "plot 'benchmark' with lines")
    And see a graph of the time it takes to compress each compression format.

  2. #2
    Just Joined! cfajohnson's Avatar
    Join Date
    May 2007
    Location
    Toronto, Canada
    Posts
    52
    Quote Originally Posted by matthewbauer View Post
    I've been trying to use the time command to benchmark the speeds of LZMA, GZIP, and BZIP2.

    So far I've come up with this command:

    Please format your code so that it can be read without horizontal scrolling.
    Code:
    for a in 100
    do
      for b in "bzip2" "lzma" "gzip"
      do
        dd if=/dev/zero of=$a.$b.zero bs=${a}M count=1
        time $b $a.$b.zero > $a.$b |
           sed "s|.* [0-9\.]*s user [0-9\.]*s system [0-9]*% cpu \([0-9\.]*\) total|\1|" >> benchmark
        echo -n "," >> benchmark
      done
      echo >> benchmark
    done
    But the problem is, the Time command seems to be able to intercept my | between Time and Sed. I have the sed to write to a file that would have the data in it.

    Is there anyway I could make this work?

    If you want to capture the output ot time:

    Code:
        { time $b $a.$b.zero > $a.$b ; } 2>&2 |

  3. #3
    Just Joined!
    Join Date
    Oct 2009
    Posts
    4
    Thanks for the help, but it's still not working.

    For example:
    Code:
    { time ls; } 2>&2 | sed "s|.*|123|"
    Will still just replace the "ls" not the "time" and if possible I'd like to stop the "ls" from displaying anything. I don't quite understand the whole 2>&2 thing so you're going to have to help me.

  4. #4
    Just Joined!
    Join Date
    Oct 2009
    Posts
    4
    bump bump

  5. #5
    Just Joined!
    Join Date
    Oct 2009
    Posts
    4
    bump bump.

  6. #6
    Just Joined! serverlinux's Avatar
    Join Date
    May 2007
    Location
    Argentina
    Posts
    64

    Wow!

    Quote Originally Posted by matthewbauer View Post
    bump bump.
    Thanks cfajohnson, very useful!
    Walter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...