Thread overview
TypeFunction ImplictConvTargets benchmark
October 07
Hello,

I recently posted a non-representative micro benchmark to showcase type functions.
And I compared two implementations of ImplicitConversionTarget reimplementations.

However I did not compare the existing implementation in phobos.

Which I have posted previously.
[https://forum.dlang.org/post/bnmjemuzwzosvglnyzbz@forum.dlang.org]

Also I made the mistake of having Adams version generate bigger tuple than the other ones, which is why it was slower.

While re-testing

I originally  wanted to test all implementations with creating the conversiontargets for ushort however ...
That resulted in my copied phobos version failing with:
xx_old.d(21): Error: undefined identifier CentTypeList
xx_old.d(46): Error: template instance xx_old.ImplicitConversionTargets!ushort error instantiating
The reason why this did not happen in the previous test where I tested conversion targets for long, is because the "CentTypeList" is not among the conversion targets for long/ulong.

Therefore I will modify the Phobos implementation and comment the mentions of CentTypeList.

As an aside that means if the template is to be believed uint can convert to ucent but ulong cannot.
It's understandable that this bug has remained hidden because ucent is not implemented yet.


And there are the results.

hyperfine -w 10 "generated/linux/release/64/dmd xx_tf.d -sktf -c -o-" "generated/linux/release/64/dmd xx_old.d -c -o-" "generated/linux/release/64/dmd xx.d -c -o-" "generated/linux/release/64/dmd xx_adam.d -c -o-"
Benchmark #1: generated/linux/release/64/dmd xx_tf.d -sktf -c -o-
  Time (mean ± σ):      10.1 ms ±   0.8 ms    [User: 6.7 ms, System: 3.3 ms]
  Range (min … max):     8.6 ms …  13.2 ms    253 runs

Benchmark #2: generated/linux/release/64/dmd xx_old.d -c -o-
  Time (mean ± σ):      10.1 ms ±   0.8 ms    [User: 6.7 ms, System: 3.2 ms]
  Range (min … max):     8.6 ms …  12.3 ms    277 runs

Benchmark #3: generated/linux/release/64/dmd xx.d -c -o-
  Time (mean ± σ):      25.3 ms ±   1.6 ms    [User: 16.1 ms, System: 8.9 ms]
  Range (min … max):    21.9 ms …  29.9 ms    104 runs

Benchmark #4: generated/linux/release/64/dmd xx_adam.d -c -o-
  Time (mean ± σ):      23.2 ms ±   1.4 ms    [User: 17.0 ms, System: 5.9 ms]
  Range (min … max):    20.5 ms …  28.1 ms    116 runs

Summary
  'generated/linux/release/64/dmd xx_tf.d -sktf -c -o-' ran
    1.00 ± 0.11 times faster than 'generated/linux/release/64/dmd xx_old.d -c -o-'
    2.31 ± 0.23 times faster than 'generated/linux/release/64/dmd xx_adam.d -c -o-'
    2.52 ± 0.25 times faster than 'generated/linux/release/64/dmd xx.d -c -o-'

As you can see the template which is listing the hand-written conversion list is on par with the type function, that generates the list from compiler internal information.
(and therefore will automatically be correct once cent/ucent are introduced.)

I will update the gist later.
October 08
What was the ram usage?
October 08
On Thursday, 8 October 2020 at 05:07:20 UTC, rikki cattermole wrote:
> What was the ram usage?

Of the phobos template slightly more than TF, but not much really.