schoel Posted June 3, 2009 Posted June 3, 2009 I moved the following script from one computer to another and the execution time increased from less than a second to more than two minutes. Does anyone have an idea why? The other computer is not a lot slower for other tasks. The script looks at each pixel in a box, starting from the upper left and then continues row by row. For each pixel, it checks the color of the pixel and then calculates a value for the pixels brightness, and after that, if the brightness is above 130 it writes 255 255 255 (white) to a file or if it is less than 130, it writes 0 0 0 (black) to the same file. When I tried this, a box 190 * 100 pixels took less than a second on one computer and more than two minutes on the other. Two minutes is painfully slow and I can't see why this happens. It's only 19000 loops, which should go quickly on a 1.8GHz dual core processor. Func Pixels($x1, $y1, $x2, $y2) DirCreate("Temp") Local $writeString = "" $nrOfCols = $x2 - $x1 + 1 $nrOfRows = $y2 - $y1 + 1 $tempFile = FileOpen("Temp\temp.pnm", 2) FileWriteLine($tempFile, "P3") FileWriteLine($tempFile, $nrOfCols & " " & $nrOfRows) FileWriteLine($tempFile, "255") For $y = $y1 To $y2 For $x = $x1 To $x2 $color = PixelGetColor($x, $y) $red = BitShift(BitAND($color, 16711680), 16) $green = BitShift(BitAND($color, 65280), 8) $blue = BitAND($color, 255) $brightness = (0.3 * $red) + (0.59 * $green) + (0.11 * $blue) If $brightness > 130 Then $writeString &= " 255 255 255" Else $writeString &= " 0 0 0" EndIf Next FileWriteLine($tempFile, $writeString) $writeString = "" Next EndFunc
Yashied Posted June 3, 2009 Posted June 3, 2009 Func Pixels($x1, $y1, $x2, $y2)What values you pass this function? Maybe they are related to resolution of the monitor? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Aceguy Posted June 3, 2009 Posted June 3, 2009 do they have the same OS.? cos if you have Aero theme on 1 pc, it makes ALOT of difference [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
schoel Posted June 3, 2009 Author Posted June 3, 2009 Func Pixels($x1, $y1, $x2, $y2)What values you pass this function? Maybe they are related to resolution of the monitor?I passed 542, 343, 732, 354. All well within the resolution of both computers.do they have the same OS.?cos if you have Aero theme on 1 pc, it makes ALOT of differenceI run Windows Vista on both. Same service packs, same version of Vista.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now