#!/bin/bash 
MAX=1000
FILENAME=testqa_originalPSDfile

function iterateConversion() {
  start=`date +%s`
  for ((i=0;i<$1;i++));
  do
    $($2) 
  done
  stop=`date +%s`
  runtime=$((stop-start))
  echo $1" iterations in "$runtime" second(s)
    for { "$2" }"
}

iterateConversion $MAX "convert -flatten $FILENAME.psd[0] $FILENAME.jpg"
iterateConversion $MAX "convert -layers merge -flatten $FILENAME.psd $FILENAME.jpg"
iterateConversion $MAX "convert $FILENAME.psd[0] $FILENAME.jpg"
