Re: slow startup on windows

Roland Hughes via Foxgui-users <[email protected]> Sat, 26 Oct 2024 18:35:52 -0500
Newsgroups gmane.comp.lib.fox-toolkit.user
Message-ID <[email protected]>
Yes, append() has to go through the long winded allocation process I 
explained earlier.

On 10/26/2024 9:50 AM, John Selverian wrote:
> This runs much faster...
>
> 	FXArray<Material> array(30000);
> 	Material str;
>
> 	for (long i = 0; i < 30000; i++)
> 	{
> 		array[i] = str;
> 		//array.append(str);
> 	}
>
>
>
>
> -----Original Message-----
> From: John Selverian <[email protected]>
> Sent: Saturday, October 26, 2024 10:44 AM
> To: '[email protected]' <[email protected]>
> Cc: '[email protected]' <[email protected]>; 'Enno
> Rehling' <[email protected]>;
> '[email protected]'
> <[email protected]>
> Subject: RE: [Foxgui-users] slow startup on windows
>
> I've traced it back to this command where I'm creating an array
> of classes (Material). This loop:
>
> 	FXArray<Material> array;
> 	Material str;
>
> 	for (long i = 0; i < 30000; i++)
> 	{
> 		array.append(str);
> 	}
>
>
> takes about 10 s on Windows and about 1 s on Windows.
>
> If I use a simpler class (something smaller than the " Material"
> class) it goes faster.
>
> To me this indicates that it's a compiler problem. I'm assuming
> only the compiler is involved in copy classes. Unless something
> is different in the implementation of FXArray.
>
> js
>
>
>
> -----Original Message-----
> From: [email protected] <[email protected]>
> Sent: Friday, October 25, 2024 2:16 PM
> To: [email protected]
> Cc: [email protected]; 'Enno Rehling'
> <[email protected]>; [email protected]
> Subject: Re: [Foxgui-users] slow startup on windows
>
> On 2024-10-25 10:43, John Selverian wrote:
>> The program is a database where everything is stored as
> strings,
>> they're all wrapped in classes, so its actually stored as a 4D
> array
>> of classes. When it's running it takes 235 MB in memory.
>>
>> The strings are not displayed in the UI.
>>
>> I timed this:
>>
>> 	FXString* tmp;
>> 	long num = 500000;
>> 	//long num = 5000000;
>> 	for (long i = 0; i < num; i++)
>> 	{
>> 		tmp = new FXString("test string");
>> 		delete tmp;
>> 	}
>>
>> For num = 500,000 it's somewhere around 1 second, for num =
>> 5,000,000 takes about 3 seconds. I also used a longer string
> ("test
>> string test string test string test string test string test
> string
>> test string test string ") and saw no effect. I'm just timing
> in the
>> debugger with a stopwatch, nothing fancy so the times are only
>> approximate but clearly noticeable.
> Of course, it depends on your machine, but it seems entirely
> reasonable.
>
> Debug vs. release may make significant difference.  Also, make
> sure target arch is set correctly [-with-arch=native optimizes
> for local machine, i.e. the one the compiler is running on].
>
> Your test is actually a-typical, you're actually doing 1,000,000
> and 10,000,000 allocations. for each i, you're allocating both
> the string and the string's buffer.
>
> Also, repeatedly allocating and freeing the same size entity will
> probably recycle memory, this is not the same as allocating NEW
> memory 500,000 times.
>
> A more fair test may be:
>
>     FXString strs = new FXString [num];
>     for (long i = 0; i < num; i++){
>        strs[i]="test string";
>     }
>     delete [] strs;
>
> This will perform num+1 allocations, num for each string's
> buffer, and one giant one for the array-of-strings.
>
>
> FYI, time of a memory allocation is somewhat independent of the
> size being allocated.  Somewhat, because once the size exceeds a
> certain value, the system will switch to an mmap call and do an
> operating system call; for the gory details, look in the file
> ~/glibc/malloc/malloc.c.
>
>
>
>     -- JVZ
>
>
>
> _______________________________________________
> Foxgui-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/foxgui-users

-- 
Roland Hughes, President
Logikal Solutions
(630)-205-1593  (cell)
https://theminimumyouneedtoknow.com
https://infiniteexposure.net
https://johnsmith-book.com