Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6847539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:45:25+00:00 2026-05-27T00:45:25+00:00

I have written a program using Free Pascal and the Lazarus IDE. In brief,

  • 0

I have written a program using Free Pascal and the Lazarus IDE. In brief, it recursively scans directories and ‘does stuff’ (hashes) with each file and then it outputs the hash values and the file name into a StringGrid, which is refreshed with each successive file.

It works great for up to a few thousand files, but when you get to the tens of thousands, it really slows down, processing maybe one file every half a second, even if it’s only a small file of a few Kb.

The main part of the code responsible is below. Can anyone see why my program slows down when the numbers of files in the grid exceeds tens of thousands?

procedure TForm1.HashFile(FileIterator: TFileIterator);
var
  SizeOfFile : int64;
  NameOfFileToHash, fileHashValue, PercentageProgress : string; 
  FI : TFileIterator;                      //File Iterator class
  SG : TStringGrid;

begin
  FI := TFileIterator.Create;
  SG := TStringGrid.Create(self);
  SizeOfFile := 0;
  fileHashValue := '';

  if StopScan = FALSE then                     // If Stop button clicked, cancel scan
    begin
    NameOfFileToHash := (FileIterator.FileName);
    SizeOfFile := FileSize(NameofFileToHash);
    StatusBar1.SimpleText := 'Currently Hashing: ' + NameOfFileToHash;
    fileHashValue := CalcTheHashFile(NameOfFileToHash); // Custom function, see below

    // Now lets update the stringgrid and text fields

    // StringGrid Elements:
    // Col 0 is FileCounter. Col 1 is File Name. Col 2 is Hash
    StringGrid1.rowcount:= FileCounter+1;
    StringGrid1.Cells[0,FileCounter] := IntToStr(FileCounter);
    Stringgrid1.Cells[1,FileCounter] := NameOfFileToHash;
    Stringgrid1.Cells[2,FileCounter] := UpperCase(fileHashValue);

    // Dynamically scroll the list so the user always has the most recently hashed
    // file insight and expand the columns in lie with their content width

    StringGrid1.row := FileCounter;
    StringGrid1.col := 1;
    StringGrid1.AutoSizeColumns;

    // Progress Status Elements: Most of these vars are global vars

    NoOfFilesExamined.Caption := IntToStr(FileCounter);
    PercentageProgress := IntToStr((FileCounter * 100) DIV NoOfFilesInDir2);
    Edit1.Caption := PercentageProgress + '%';
    TotalBytesRead := TotalBytesRead + SizeOfFile;
    edtTotalBytesExamined.Caption := FormatByteSize(TotalBytesRead);

    Application.ProcessMessages;
    FileCounter := FileCounter+1;
    end;
  SG.Free;
  FI.Free;
end;

The full source code is available from my SourceForge page, https://sourceforge.net/projects/quickhash/ under ‘Files’ –> ‘Source Code’ if you need that.

Any help appreciated

Ted

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:45:25+00:00Added an answer on May 27, 2026 at 12:45 am

    Well as a Delphi bloke two things popped out at me.
    AutoSizeColumns. If you are lucky it’s doing nothing. If it’s marching down all columns in 10,000 rows, every update and doing a GetTextLength to see if it fits, then repainting the grid….

    So job 1 would be to preset some column sizes and comment that out.
    Do it once at the end of the scan at most.

    Who is going to want to see all 10,000 + rows at once?

    I think I’d stream them out to file, and show the last 1 – page full to indicate progress. Then I’d drive my ui from the file, using a simple get a page full scenario.
    Depends on what you are doing with the data, but you could reload file for further analyis, do a compare for changes.

    Even if you stick with in memory Have a TList? of THashRecord. Then drive your display from that, you’ll have a chance then.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written this program, which sorts some ints using a functor: #include<iostream> #include<list>
I'm using Visual Studio 2005. I have a program written in C#. When I
I have a console program written in C# that I am using to send
I've written a program in C++. It's just using the console to have it
I have written a program which will serialize and de-serialize, it does this fine
I have written a program in C# using Visual Studio 2010. At current it
I have written a simple C program using gcc compiler in Ubuntu enviroment. The
I have written a simple network program on java using sockets. Program has a
I have written a simple network program on java using sockets. Program has a
I have written a program in PowerShell that loops and checks stuff. I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.