Results are different with Mono on Windows -> it doesn't get affected by
the "hashtable", although in Mono there's a different performance hit ->
if you read fields by field name instead of index your speed is slowed
down to a half
[EMAIL PROTECTED] escribió:
> No, I didn't.
>
> As I told this is not a *real* production code. What I actually do in
> the real code is add one object per record, so my sample was right.
>
> The problem is why adding to a hashtable kills reader performance...
>
> Steve Faleiro escribió:
>
>>>> while( reader.Read() )
>>>> {
>>>> for( int j = 0; j < reader.FieldCount; ++j )
>>>> val=reader[j];
>>>> // table.Add(count, val);
>>>> ++count;
>>>> }
>>>>
>>>>
>> while( reader.Read() )
>> {
>> for( int j = 0; j < reader.FieldCount; ++j )
>> {
>> val=reader[j];
>> table.Add(count, val);
>> }
>> ++count;
>> }
>>
>>
>> Perhaps you meant to do this?
>>
>>
>> --- "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>>> Hi there,
>>>
>>> Here I'm trying to save some miliseconds with the Firebird provider
>>> (using embedded database!)
>>>
>>> Well, I've a weird problem and I'd like you to take a look into it.
>>>
>>> Well, I'm using the following code to read data from a Firebird
>>> database:
>>>
>>> object val;
>>>
>>> while( reader.Read() )
>>> {
>>> for( int j = 0; j < reader.FieldCount; ++j )
>>> val=reader[j];
>>> // table.Add(count, val);
>>> ++count;
>>> }
>>>
>>> I'm reading 416310 records.
>>>
>>> Well, in my poor-slow laptop it takes 50 seconds to read all data.
>>>
>>> The "funny" thing is: did you see the commented out code? Well, it
>>> just
>>> adds the last read field from the record to a hash table. It doesn't
>>> make any sense, it is just a test case extracted from real code, so
>>> don't try to find any logic.
>>>
>>> Well, the point is: if I uncomment the line -> it takes 158 seconds to
>>>
>>> read the 416310 records!!!
>>>
>>> Ok, now you're thinking: yes, that's because adding to the hashtable
>>> is
>>> slow. Check the following code:
>>>
>>> Hashtable table = new Hashtable();
>>>
>>> int ini = Environment.TickCount;
>>>
>>> for( int i = 0; i < 416310; ++i )
>>> table.Add(i, new object());
>>>
>>> Console.WriteLine(
>>> "Time to add {0} objects = {1} ms",
>>> table.Count,
>>> Environment.TickCount - ini);
>>>
>>> It takes 250 ms (miliseconds!) to add the same number of dumb objects
>>> to
>>> the Hashtable!!
>>>
>>> So, somehow, adding records to the Hashtable breaks reader
>>> performance!!! I'm going crazy, and yes, I've repeated the results on
>>> a
>>> different computer with different OS and I get the same relative
>>> results!
>>>
>>> If you change the Hashtable by an ArrayList... performance hit goes
>>> away!!
>>>
>>> Ideas???
>>>
>>>
>>> Thanks
>>>
>>>
>>> pablo
>>>
>>>
>>>
>>>
>> -------------------------------------------------------------------------
>>
>>
>>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>>> challenge
>>> Build the coolest Linux based applications with Moblin SDK & win great
>>> prizes
>>> Grand prize is a trip for two to an Open Source event anywhere in the
>>> world
>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>> _______________________________________________
>>> Firebird-net-provider mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
>>>
>>>
>>>
>>
>>
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Firebird-net-provider mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
>>
>>
>>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Firebird-net-provider mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider