News for hackers. Stuff that matters.
Re:Minimalism in programming language design by _gabe_ on Tuesday May 24, 2022 @01:02PM (#31494688)
Yep you are correct, I was mis-remembering quite a bit. I just re-ran the tests using BenchmarkDotNet and C# takes 124 nanoseconds on average, which is still 100x slower and a considerable difference, but not orders of magnitude difference :)

C# benchmarks on my machine. FastFindRecipe just does a hash set lookup, it looks like this:

  private static readonly HashSet<CraftingRecipe> FastList = new HashSet<CraftingRecipe>(new CraftingComparer());
  public static CraftingRecipe? FastFind(CraftingRecipe r) => FastList.TryGetValue(r, out var res) ? res : null;

  |         Method |     Mean |   Error |  StdDev |      Min |      Max |
  |--------------- |---------:|--------:|--------:|---------:|---------:|
  |     FindRecipe | 315.2 ns | 1.17 ns | 1.09 ns | 313.6 ns | 317.4 ns |
  | FastFindRecipe | 124.5 ns | 0.23 ns | 0.21 ns | 124.1 ns | 124.9 ns |
Re:Minimalism in programming language design by avgcorrection on Tuesday May 24, 2022 @02:03PM (#31495437)
> , which is still 100x slower and a considerable difference, but not orders of magnitude difference :)

Two orders of magnitude.