Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Fedor  
#1 Posted : Tuesday, October 11, 2005 6:00:00 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,550

Thanks: 5 times
Was thanked: 59 time(s) in 58 post(s)
When you navigate into a folder with hundreds files you may notice that Image Uploader scans the folder very long (up to tens seconds). This article describes reasons and gives guidelines how to make it faster.

Overview

When you are using Image Uploader with certain settings, you may notice that if you enter some folder which contains hundreds of images, it scans this folder very long. E.g. at machine with Athlon(tm) XP 1700+ CPU and 256 MB RAM it takes about 14 seconds to read a folder with 300 files.

While folder is scanned, Image Uploader displays "Loading files..." message and user is not able to do anything but wait. It is obviously seems the user tiresome and annoying.

Reason

It happens if you specifying file limitations, e.g. max/min dimension (MaxImageWidth, MaxImageHeight, MinImageWidth, and MinImageHeight properties). Operation of extraction of width/height and determining file type is quite long (comparing to other actions). Image Uploader should open file and partially parse it (of course it does not read entire file into memory, but it still works long). When these operations are applied to few files, the performance loss is almost invisible, but for hundreds files it becomes too large.

At the same time some limitation properties does not noticeable affects the performance. For example, file mask (FileMask property) and file size (MaxFileSize property) checks are done quickly even for hundreds files.

Solution

The single way to make it working fast is to disable checks for signature and dimensions. In other words you should use the following values for these limitation parameters:

Code:
iu.addParam("MaxImageWidth", "0");
iu.addParam("MaxImageHeight", "0");
iu.addParam("MinImageWidth", "0");
iu.addParam("MinImageHeight", "0");


As long as you update these parameters, it will work as fast as Windows Explorer (i.e. assemble file list less than for 1 second even for hundreds files).

However this way you cannot use client-side validation for files. Therefore you have a choice - use slow checks during folder scanning or make it faster by removing all the checks. Note, as soon as you enable at least one of these checks, the speed is dramatically dropped. There is no noticeable difference between only one such check or all five ones. None checks - folder scan is made in less than 1 second, one check - it will work 14 seconds, all five checks - it will work 14 seconds too (these numbers where taken for the situation described in the overview).

Fortunately there is a workaround that allows put the validation off till user add the file into upload queue. It will require adding some JavaScript. The idea is to handle UploadFileCountChange event which fires every time user adds a file into upload list or vice versa - removes it. As long as you have access to the collection of files selected for upload, you can analyze them and remove it from upload list if it does not conform your limitations.

Edited by user Wednesday, January 2, 2008 4:50:38 PM(UTC)  | Reason: Not specified

Best regards,
Fedor Skvortsov
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.