Re: [fpc-pascal] Happy tickets benchmark [OT]

2016-02-19 Thread Lukasz Sokol
On 18/02/16 11:15, Serguei TARASSOV wrote:
> On 18/02/2016 12:00, fpc-pascal-requ...@lists.freepascal.org wrote:
>> Date: Wed, 17 Feb 2016 18:55:29 +0100
>> From: Adrian Veith
>> To: FPC-Pascal users discussions
>> Subject: Re: [fpc-pascal] Happy tickets benchmark
>>
>> I don't want to insist on this, but: if you measure the runtime of your
>> program you result = runtime + error. If you measure a series against
>> MIN you measure MIN(result) = runtime + MIN(error) which delivers the
>> best value for runtime.
> Not at all, any series against MIN delivers the best value for MIN(result) 
> not for runtime!
> 
Std deviation also matters:
> Ex.
> Prog 1
> Run 1: 130 = 100 + 30
> Run 2: 160 = 100 + 60
> Run 3: 170 = 100 + 70

> Min = 130, Avg = 153
> 
std dev = 17

> Prog 2
> Run 1: 120 = 110 + 10
> Run 2: 150 = 110 + 40
> Run 3: 200 = 110 + 90
> Min = 120, Avg = 157

std dev = 33 

> MIN shows that Prog 2 is faster that is wrong.
> AVG shows that Prog 1 is faster.
> 
Std dev shows that runs of Prog2 have more error 
so its measurements can't be trusted /more/ than Prog1.

The sample also is too small for meaningful statistics ;)

> Regards,
> Serguei

-L.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] [OT] News-Flash: fpc-other is now on Gmane !

2016-02-19 Thread Lukasz Sokol
Yay 

http://dir.gmane.org/gmane.comp.compilers.free-pascal.social

However has not yet hit the gmane nntp hierarchy (at the time of writing this 
post);

The first post it lists is the Lazarus 1.6 Announcement
Date: 2016-02-18 15:28:27 GMT (18 hours and 21 minutes ago)

So I could not subscribe to it with my Thunderbird (yet).

(this apparently is /not/ something I could filter out of the Gmane FAQ,
other than it can take up to 2 weeks since subscribtion - 
so I guess a post to gmane.discuss would be in order, but let's give
them some more time. Say, next week?)

But this is very welcome anyway :)

-L.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] [PATCH] Addition of OnNotify event on "TFPGObjectList" and "TFPGList" triggered on the insert, delete and extract methods.

2016-02-19 Thread silvioprog
Hello,

I have a friend here in Brazil that added the `notify` support to the FGL
lists, however he sented it to this Github PR [1].

I'm contacting him to explain how to send it to FPC bugtracker, so you can
disconsider this PR at Github. :-)

Thank you!

[1]
https://github.com/fabianosalles/freepascal/commit/1d4cc907c806563c19e682676ac0e6676ae0a82b

--
Silvio Clécio
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Happy tickets benchmark

2016-02-19 Thread Serguei TARASSOV

On 17/02/2016 12:00, fpc-pascal-requ...@lists.freepascal.org wrote:

Date: Tue, 16 Feb 2016 12:48:31 +0100 (CET)
From: Michael Van Canneyt
To: FPC-Pascal users discussions
Subject: Re: [fpc-pascal] Happy tickets benchmark


I have asked Florian to integrate his patch anyway, he has agreed,
so I imagine it will result in a new -OoNNN switch.

Michael.

Good news.
Do you have any ideas why this kind of optimization is special?

For info, simple loop test like

  while i < 10 do
i := i + 1;

shows that the FPC code is 2 times slower than Delphi 7 and Borland C 
5.5 and 4 times slower that C#.


Regards,
Serguei

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc-pascal Digest, Vol 140, Issue 69

2016-02-19 Thread Serguei TARASSOV

On 19/02/2016 12:00, fpc-pascal-requ...@lists.freepascal.org wrote:

Message: 2
Date: Fri, 19 Feb 2016 09:16:15 +
From: Lukasz Sokol
To:fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Happy tickets benchmark [OT]

Std deviation also matters:
Std dev shows that runs of Prog2 have more error
so its measurements can't be trusted/more/  than Prog1.

The sample also is too small for meaningful statistics;)

Exactly, the variance too. Many things matter.
My example shows only that AVG estimation is better than MIN in the 
simple technical test with 10 runs because of average the runtime "noise".

I suppose it could be approved more strictly.

Regards,
Serguei
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Happy tickets benchmark

2016-02-19 Thread Jonas Maebe

Serguei TARASSOV wrote:

For info, simple loop test like

   while i < 10 do
 i := i + 1;

shows that the FPC code is 2 times slower than Delphi 7 and Borland C
5.5 and 4 times slower that C#.


If that's really all there is in your program, then the C# compiler 
probably replaces that with "i+=10;" (gcc and clang definitely 
will do that, I don't know about Delph 7/Borland C 5.5). This is another 
kind of optimisation that is seldom useful in real world programs 
(normally the loop will also do something useful, in which case you 
can't do that).


FPC indeed does not implement many of these optimisations, because we 
prefer to spend our time on other things. If you, or anyone else, wants 
to implement transformations for such idioms, you're welcome and we'll 
happily apply your patches if they are implemented as generic node tree 
optimisation passes.



Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] [PATCH] Addition of OnNotify event on "TFPGObjectList" and "TFPGList" triggered on the insert, delete and extract methods.

2016-02-19 Thread Sven Barth
Am 19.02.2016 12:45 schrieb "silvioprog" :
>
> Hello,
>
> I have a friend here in Brazil that added the `notify` support to the FGL
lists, however he sented it to this Github PR [1].

I'm against that. That would negatively impact the performance of these
lists.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] [PATCH] Addition of OnNotify event on "TFPGObjectList" and "TFPGList" triggered on the insert, delete and extract methods.

2016-02-19 Thread silvioprog
On Fri, Feb 19, 2016 at 10:24 AM, Sven Barth 
wrote:

> Am 19.02.2016 12:45 schrieb "silvioprog" :
> >
> > Hello,
> >
> > I have a friend here in Brazil that added the `notify` support to the
> FGL lists, however he sented it to this Github PR [1].
>
> I'm against that. That would negatively impact the performance of these
> lists.
>
As I said, please discard this PR, because I'm contacting the member
(Fabiano) to use mantis instead of Github, and I received other patch from
other guy (Gilson) improving this changes.

-- 
Silvio Clécio
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Happy tickets benchmark

2016-02-19 Thread leledumbo
> Do you have any ideas why this kind of optimization is special?

Didn't Florian said that this kind of optimization has no benefit in real
world programs and will only increase compilation time?

> For info, simple loop test like 
>
>   while i < 10 do 
> i := i + 1; 
>
> shows that the FPC code is 2 times slower than Delphi 7 and Borland C 
> 5.5 and 4 times slower that C#.

Just checked such a code with gcc 5.3.0, in -O2 the generated assembly is:

xorl%eax, %eax
ret

which literally does nothing. Without optimization the speed is equal.



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Happy-tickets-benchmark-tp5724109p5724197.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] [PATCH] Addition of OnNotify event on "TFPGObjectList" and "TFPGList" triggered on the insert, delete and extract methods.

2016-02-19 Thread Sven Barth
Am 19.02.2016 14:45 schrieb "silvioprog" :
>
> On Fri, Feb 19, 2016 at 10:24 AM, Sven Barth 
wrote:
>>
>> Am 19.02.2016 12:45 schrieb "silvioprog" :
>> >
>> > Hello,
>> >
>> > I have a friend here in Brazil that added the `notify` support to the
FGL lists, however he sented it to this Github PR [1].
>>
>> I'm against that. That would negatively impact the performance of these
lists.
>
> As I said, please discard this PR, because I'm contacting the member
(Fabiano) to use mantis instead of Github, and I received other patch from
other guy (Gilson) improving this changes.

It doesn't matter whether it is requested over here or on Mantis. I'm
against adding notifications to the generic lists, because that will
degrade their performance.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] [PATCH] Addition of OnNotify event on "TFPGObjectList" and "TFPGList" triggered on the insert, delete and extract methods.

2016-02-19 Thread silvioprog
On Fri, Feb 19, 2016 at 4:20 PM, Sven Barth 
wrote:
[...]

> It doesn't matter whether it is requested over here or on Mantis. I'm
> against adding notifications to the generic lists, because that will
> degrade their performance.
>
Can you send little bit sample showing this degradation? I can inform him
to not send the patch because this problem. (I think that him isn't
registered here in the list yet)

-- 
Silvio Clécio
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] [PATCH] Addition of OnNotify event on "TFPGObjectList" and "TFPGList" triggered on the insert, delete and extract methods.

2016-02-19 Thread Sven Barth
Am 19.02.2016 20:47 schrieb "silvioprog" :
>
> On Fri, Feb 19, 2016 at 4:20 PM, Sven Barth 
wrote:
> [...]
>
>> It doesn't matter whether it is requested over here or on Mantis. I'm
against adding notifications to the generic lists, because that will
degrade their performance.
>
> Can you send little bit sample showing this degradation? I can inform him
to not send the patch because this problem. (I think that him isn't
registered here in the list yet)

There's no need for a sample. This degradation is the whole reason why the
non-generic classes TFPObjectList and TFPList exist compared to TObjectList
and TList which do have notifications.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] [PATCH] Addition of OnNotify event on "TFPGObjectList" and "TFPGList" triggered on the insert, delete and extract methods.

2016-02-19 Thread Graeme Geldenhuys
On 2016-02-19 23:04, Sven Barth wrote:
> There's no need for a sample. This degradation is the whole reason why the
> non-generic classes TFPObjectList and TFPList exist compared to TObjectList
> and TList which do have notifications.

I don't use Generics so it doesn't bother me either way. But purely from
a software design point of view, it should be quite easy to create a
list where notification can be enabled or disabled at runtime - maybe as
a parameter to the constructor or via a property. On disabling
notification there should be near zero degradation - at least not
something noticeable.

Just my 2¢ worth.


Regards,
  - Graeme -

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] How to pass an array of bytes directly in a TBytes param?

2016-02-19 Thread silvioprog
Hello,

Consider the following procedure:

procedure test(b: TBytes);
begin
end;

The common way to pass an array of bytes in this procedure is declaring and
initializing a TBytes variable. But in Delphi (XE) I just do:

  test([65, 66, 67]);

However, when I try it on FPC (trunk), I get:

"Error: Incompatible type for arg no. 1: Got "{Array Of Const/Constant
Open} Array of ShortInt", expected "TBytes"".

Is this feature supported in FPC? If so, how to use that?!

Thank you!

-- 
Silvio Clécio
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] How to pass an array of bytes directly in a TBytes param?

2016-02-19 Thread Dmitry Boyarintsev
procedure test(const b: array of byte) ??

On Friday, February 19, 2016, silvioprog  wrote:

> Hello,
>
> Consider the following procedure:
>
> procedure test(b: TBytes);
> begin
> end;
>
> The common way to pass an array of bytes in this procedure is declaring
> and initializing a TBytes variable. But in Delphi (XE) I just do:
>
>   test([65, 66, 67]);
>
> However, when I try it on FPC (trunk), I get:
>
> "Error: Incompatible type for arg no. 1: Got "{Array Of Const/Constant
> Open} Array of ShortInt", expected "TBytes"".
>
> Is this feature supported in FPC? If so, how to use that?!
>
> Thank you!
>
> --
> Silvio Clécio
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] How to pass an array of bytes directly in a TBytes param?

2016-02-19 Thread silvioprog
On Fri, Feb 19, 2016 at 10:37 PM, Dmitry Boyarintsev <
skalogryz.li...@gmail.com> wrote:

> procedure test(const b: array of byte) ??


I know it using an array of bytes, but does it compiles if the parameter is
declared as TBytes? I don't know if FPC sopports it, so I'm askig just to
check if it is possible (enabling some switch).

--
Silvio Clécio
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] [PATCH] Addition of OnNotify event on "TFPGObjectList" and "TFPGList" triggered on the insert, delete and extract methods.

2016-02-19 Thread Michalis Kamburelis
>> Can you send little bit sample showing this degradation? I can inform him
>> to not send the patch because this problem. (I think that him isn't
>> registered here in the list yet)
>
> There's no need for a sample. This degradation is the whole reason why the
> non-generic classes TFPObjectList and TFPList exist compared to TObjectList
> and TList which do have notifications.

Hm, two points.

1. I'm using FGL containers a lot (because I like type-safety given by
generics), and I agree that adding a notification mechanism there can
slow them down. Mostly at allocation (because a deallocation is
already burdened down by having to do Deref() on every item, so it
would probably not suffer *so much* with unassigned OnNotify).

2. But this should not stop us from making a "generic container with
notification" classes. Maybe as new classes, maybe as a boolean toggle
to existing classes (as Graeme nicely suggests).

  Right now we only have "with notifications, and not type-safe"
containers (TObjectList/TList) and "without notifications, and
type-safe using generics" containers (TFPObjectList/TFPList). But
these two features (1. notifications and 2. type-safety thanks to
generics) should be independent. It makes sense to create a "with
notifications, and type-safe using generics" option.

  So I would not reject the idea so quickly. But it indeed should be
implemented carefully, without slowing down the existing
TFPObjectList/TFPList.

Regards,
Michalis
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Primitive Record Wrappers

2016-02-19 Thread Michalis Kamburelis
2016-02-18 15:43 GMT+01:00 Mazola Winstrol :
> Em 18/02/2016 10:12, "Marco van de Voort"  escreveu:
>>
>> In our previous episode, Mazola Winstrol said:
>> >end;
>> >
>> >
>> > Suppose that this class represent data of the Person table in a sql
>> > database. Suppose that there is records where the column "BirthDate" is
>> > null. How do i represent a null "BirthDate" in my object?
>>
>> Keep using variants instead of typed data.
>>
>
> I think this is not a good alternative. As the variant are untyped, should
> the consumers of the person class assume that BirthDate are filled as a
> formated date string '01/01/1980' or as a native tdatetime?
>
> I think it would be better using record wrappers to primitive types. See
> http://blogs.embarcadero.com/abauer/2008/09/18/38869.
>
> What do you think about that?

Personally, I like the Nullable idea from C#, which is basically a
generic record adding a "HasValue: boolean" to "Value: T". The
type-safety is nice, and it's sometimes very useful (when you cannot
"cheat" and say that "empty string" or "zero value" always means
"uninitialized"). Looking at your link
http://blogs.embarcadero.com/abauer/2008/09/18/38869 , this is exactly
trying to implement Nullable in Object Pascal.

The major problem there is that it's difficult to force it to be
always initialized with zeroes. Currently, a non-global variable of
unmanaged type can always be filled with memory garbage, as explained
in other thread. The trick in
http://blogs.embarcadero.com/abauer/2008/09/18/38869 to use interfaces
feels ugly, it's an over-use of the "interface" specifics in Object
Pascal.

I remember a thread on fpc-devel "Pascal Smart Pointers Idea + ARC
implementation" where the original author (Maciej Izak) was already
working to overcome this:
https://www.mail-archive.com/fpc-devel@lists.freepascal.org/msg33172.html
. His reasons was similar (force the contents to be initialized with
zero) and his solution felt cleaner -- introduce "class operator
Initialize" where you can initialize your record.

Any chance that this would be added/merged to FPC one day?:)

Regards,
Michalis
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] [PATCH] Addition of OnNotify event on "TFPGObjectList" and "TFPGList" triggered on the insert, delete and extract methods.

2016-02-19 Thread Maciej Izak
Notifications events already works in Generics.Collections. ;P
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal