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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:34:41+00:00 2026-05-21T04:34:41+00:00

i have a struture like this const MaxSignalRecords=255; type TSignalRecord=record signal1 : integer; signal2

  • 0

i have a struture like this

const
  MaxSignalRecords=255;
type
  TSignalRecord=record
   signal1  : integer;
   signal2  : integer;
   signal3  : integer;
   signal4  : integer;
   signal5  : integer;
   signal6  : integer;
   bsignal1 : Boolean;
   bsignal2 : Boolean;
   bsignal3 : Boolean;
   bsignal4 : Boolean;
   bsignal5 : Boolean;
   bsignal6 : Boolean;
  end;

TListSignals = Array[0..MaxSignalRecords-1] of TSignalRecord;

and a procedure to generate random sample data

Procedure FillRandomListSignals(var ListSignals:TListSignals);
var
  i :Integer;
begin
  for i := 0 to MaxSignalRecords - 1 do
  with ListSignals[i] do
  begin
   signal1   :=Random(MaxInt);
   signal2   :=Random(MaxInt);
   signal3   :=Random(MaxInt);
   signal4   :=Random(MaxInt);
   signal5   :=Random(MaxInt);
   signal6   :=Random(MaxInt);
   bsignal1  :=Boolean(Random(2));
   bsignal2  :=Boolean(Random(2));
   bsignal3  :=Boolean(Random(2));
   bsignal4  :=Boolean(Random(2));
   bsignal5  :=Boolean(Random(2));
   bsignal6  :=Boolean(Random(2));
  end;
end;

How i can improve the performance of the FillRandomListSignals procedure ?

Edit : this structure is used to make thousands(can be millions) of calculations

for i:=1 to 1000000 do
begin
  CleartheList(MyList);
  FillRandomListSignals(MyList);
  DotheMath(MyList);
  DotheChart(MyList);
end;
  • 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-21T04:34:42+00:00Added an answer on May 21, 2026 at 4:34 am

    Speed is not your only concern when you generate random data, you actually want that data to be random, you don’t want your experiment to be plagued by repetitive data or other pseudo-random generator problems. If you care more about speed then randomness, you can always use a function like this one, that’ll be ultra-fast! </joke>.

    Here’s a post by Barry Kelly on Stack Overflow describing possible problems with the built-in random number generator. Not going to quote it here, go read it for yourself, it’s good stuff.

    To get to the conclusion, when I needed a PRNG good enough to generate huge amounts of random data I used a Mersenne Twister (wikipedia link), seeded by Delphi’s PRNG.

    Quote from Wikipedia on Mersene Twister:

    For many applications the Mersenne twister is quickly becoming the pseudorandom number generator of choice. The Mersenne Twister is designed with Monte Carlo simulations and other statistical simulations in mind. Researchers primarily want high quality numbers but also benefit from its speed and portability.

    And to break all my records on the number of links per post, I used this Delphi implementation.

    And my final thought: Unless you’re very good with math, stay away from home-made PRNG implementations. Just like hash functions, it’s easy to make a mistake and they’re very difficult to analyze.


    Edit

    Did some timing, using the following code. The 10,000,000 records took 1480 ms to generate using the Mersenne Twister. The same code, using Delphi’s built in random number generator only took 250 ms, for the same 10M records. Something tells me it’s not the random generator that needs optimizing, but something else in the code.

    procedure TForm1.Button1Click(Sender: TObject);
    var InitArray:array[0..99] of LongInt;
    
        i, N:Integer;
        TSR: TSignalRecord;
    
        CStart, CStop: Int64;
    
    begin
      Randomize;
      for i:=0 to 99 do InitArray[i] := Random($effffff);
      InitMTbyArray(InitArray, Length(InitArray));
    
      CStart := GetTickCount;
    
      for i:=1 to 10000000 do
      begin
        TSR.signal1 := IRanMT;
        TSR.signal2 := IRanMT;
        TSR.signal3 := IRanMT;
        TSR.signal4 := IRanMT;
        TSR.signal5 := IRanMT;
        TSR.signal6 := IRanMT;
    
        N := IRanMT;
    
        TSR.bsignal1 := (N and 1) <> 0;
        TSR.bsignal2 := (N and 2) <> 0;
        TSR.bsignal3 := (N and 4) <> 0;
        TSR.bsignal4 := (N and 8) <> 0;
        TSR.bsignal5 := (N and 16) <> 0;
        TSR.bsignal6 := (N and 32) <> 0;
      end;
    
      CStop := GetTickCount;
    
      Caption := IntToStr(CStop - CStart);
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a structure defined like this: const MaxSignalRecords=255; type TSignalRecord=record signal1 : integer;
I have a structure like this. struct A { int someFun() const; int _value;
I have a procedure that expects a parameter of type TObject, something like this:
I have a file structure like this: file1.h extern const char *build_info[][3]; file1.cpp #include
I have a structure like this.... UITableViewController -> UITableViewCell -> UIView I need the
I have xml structure like this: <Group id=2 name=Third parentid=0 /> <Group id=6 name=Five
The typical Python threadpool will have a structure like this one: def run(self): while
In an ASP.NET MVC3 project I have a structure like this: Core.csproj -> 3rdparty1.dll
I have a folder structure like this: /some_folder /tmp /tmp/foo /tmp/foo/fu * /tmp/bar /tmp/bar/bah
I have a folder structure like this: /articles .index.php .second.php .third.php .fourth.php If I'm

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.