Show
Ignore:
Timestamp:
10/24/09 21:03:55 (5 months ago)
Author:
cristy
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ImageMagick/trunk/utilities/convert.c

    r249 r449  
    4848  Include declarations. 
    4949*/ 
    50 #include <stdio.h> 
    51 #include <stdlib.h> 
    52 #include <string.h> 
    53 #include <time.h> 
    54 #include <math.h> 
     50#include "magick/studio.h" 
     51#include "magick/thread-private.h" 
    5552#include "wand/MagickWand.h" 
    5653#if defined(__WINDOWS__) 
     
    7774 
    7875  double 
     76    duration, 
    7977    elapsed_time, 
    8078    user_time; 
     
    8684    *image_info; 
    8785 
     86  long 
     87    j; 
     88 
    8889  MagickBooleanType 
     90    concurrent, 
    8991    regard_warnings, 
    9092    status; 
     
    100102 
    101103  MagickCoreGenesis(*argv,MagickTrue); 
     104  concurrent=MagickFalse; 
     105  duration=(-1.0); 
    102106  exception=AcquireExceptionInfo(); 
    103107  iterations=1; 
    104   status=MagickFalse; 
     108  status=MagickTrue; 
    105109  regard_warnings=MagickFalse; 
    106110  for (i=1; i < (long) (argc-1); i++) 
     
    111115    if (LocaleCompare("bench",option+1) == 0) 
    112116      iterations=(unsigned long) atol(argv[++i]); 
     117    if (LocaleCompare("concurrent",option+1) == 0) 
     118      concurrent=MagickTrue; 
    113119    if (LocaleCompare("debug",option+1) == 0) 
    114120      (void) SetLogEventMask(argv[++i]); 
     121    if (LocaleCompare("duration",option+1) == 0) 
     122      duration=(unsigned long) atof(argv[++i]); 
    115123    if (LocaleCompare("regard-warnings",option+1) == 0) 
    116124      regard_warnings=MagickTrue; 
     
    119127  if (iterations > 1) 
    120128    timer=AcquireTimerInfo(); 
    121   for (i=0; i < (long) iterations; i++) 
     129  if (concurrent != MagickFalse) 
     130    SetOpenMPNested(1); 
     131  # pragma omp parallel for shared(status) 
     132  for (i=0; i < (long) (concurrent != MagickFalse ? iterations : 1); i++) 
    122133  { 
    123     image_info=AcquireImageInfo(); 
    124     status=ConvertImageCommand(image_info,argc,argv,(char **) NULL,exception); 
    125     if (exception->severity != UndefinedException) 
    126       { 
    127         if ((exception->severity > ErrorException) || 
    128             (regard_warnings != MagickFalse)) 
    129           status=MagickTrue; 
    130         CatchException(exception); 
    131       } 
    132     image_info=DestroyImageInfo(image_info); 
     134    if (status == MagickFalse) 
     135      continue; 
     136    if (GetElapsedTime(timer) > duration) 
     137      continue; 
     138    ContinueTimer(timer); 
     139    for (j=0; j < (long) (concurrent == MagickFalse ? iterations : 1); j++) 
     140    { 
     141      if (status == MagickFalse) 
     142        break; 
     143      if (GetElapsedTime(timer) > duration) 
     144        break; 
     145      ContinueTimer(timer); 
     146      image_info=AcquireImageInfo(); 
     147      status=ConvertImageCommand(image_info,argc,argv,(char **) NULL,exception); 
     148      # pragma omp critical (MagickCore_Convert_Utility) 
     149      if (exception->severity != UndefinedException) 
     150        { 
     151          if ((exception->severity > ErrorException) || 
     152              (regard_warnings != MagickFalse)) 
     153            status=MagickTrue; 
     154          CatchException(exception); 
     155        } 
     156      image_info=DestroyImageInfo(image_info); 
     157    } 
    133158  } 
    134159  if (iterations > 1)