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 9278447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:22:24+00:00 2026-06-18T17:22:24+00:00

I am looking for a timer in milliseconds or nanoseconds in Delphi7. I have

  • 0

I am looking for a timer in milliseconds or nanoseconds in Delphi7. I have to check the speeds of three ISAM files with sequential search. The first ind file contains 50 strings like “record_0” to “record_50”. The second – “record_0” to “record_500” and the third – “record_0” to “record_5000”. I’ve implemented everything but I don’t know how to make the timer. I am comparing a string with the last item in each ISAM file. Here is my code for the first ind file:

procedure TForm1.Button1Click(Sender: TObject);
  var i:integer;
  var content : String[20];
  var indexCounter:integer;
  var keyword:string;
begin
  //First ISAM file
  AssignFile(indF1, 'index1.ind');
  ReWrite(indF1);
  Reset(indF1);
  for i:=0 to 49 do begin
    content := 'record_';
    content := content + IntToStr(i+1);
    index1.index1 := content;
    index1.position1 := FileSize(indF1);
    Seek(indF1, FileSize(indF1));
    write(indF1, index1);
  end;
  CloseFile(indF1);
  Label12.Caption := FileSizeStr('index1.ind');

  //Sequential search in first ind file
  Reset(indF1);
  keyword := 'record_50';
  indexCounter := 0;
  //start timer
  while not Eof(indF1) do begin
    Seek(indF1, indexCounter);
    Read(indF1, Index1);
    if (keyword = Index1.index1) then begin
      //stop timer;
      //Label20 := milliseconds/nanoseconds;
      //return/break while loop (result := -1; exit;) ???
    end;
    indexCounter := indexCounter + 1;
  end;

I need a procedure/function so that when I call it it should start counting in milliseconds or nanoseconds and stop when the string is found (it’s the last string in each ind file) and show the elapsed time for traversing through all the file. Also I don’t know how to break the while loop. Thanks in advance.

  • 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-06-18T17:22:26+00:00Added an answer on June 18, 2026 at 5:22 pm

    The TStopWatch class described here "delphi-high-performance-timer-tstopwatch" has all functions needed (for Delphi-7).

    It’s implemented in later Delphi versions (Delphi-2010) as an advanced record in unit diagnostics.

    Example:

    var
      sw : TStopWatch;
      elapsedMilliseconds : cardinal;
    begin
      ...
      sw := TStopWatch.Create() ;
      try
        sw.Start;
    
        while not Eof(indF1) do begin
          Seek(indF1, indexCounter);
          Read(indF1, Index1);
          if (keyword = Index1.index1) then begin
            sw.Stop;
            Label20.Caption := IntToStr(sw.ElapsedMilliseconds);
            break; // break while loop
          end;
          indexCounter := indexCounter + 1;
        end;
        ...
      finally
        sw.Free;
      end;
    end;
    

    To break the while loop, just do break; inside your conditional test.

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

Sidebar

Related Questions

I have spent way too much time looking for the files owner icon to
I have the code: var timer:Timer = new Timer(milliseconds, repititions); timer.addEventListener(TimerEvent.TIMER, callback); timer.start(); and
I've been looking into the Timer class ( http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx ), but the thing about
I'm looking for a repeating timer object that allows me to create it once
I have spent much time looking for a special package that could run the
I have been looking for some time for this and I can't seem to
I was looking for a Java timer sample and found the code below at
I have a basic question regarding timers. My timer is acting very strange. I
I'm looking for an JavaScript algorithm to convert local calendar date-times into UTC milliseconds
I'm looking to implement a simple timer mechanism in C++. The code should work

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.