title: Why sol2 is slower than LuaBridge3?
body: <p>I've done some benchmarks (<a href="https://github.com/Alterise/lua-benchmarks" rel="nofollow noreferrer">lua-benchmarks</a>).
  For some reason sol2 perform slower than LuaBridge3. <br />
  In sol2 repo you can find benchmarks showing that sol2 have to outperform LuaBridge3 (<a href="https://sol2.readthedocs.io/en/latest/benchmarks.html" rel="nofollow noreferrer">benchmarks</a>), but for some reason on real use cases it's not. <br />
  In LuaBridge3 docs you can find that statement (<a href="https://kunitoki.github.io/LuaBridge3/Manual#11---design" rel="nofollow noreferrer">LuaBridge3 docs</a>):</p>
  <blockquote>
  <p>Although it comes close to the highest possible performance, LuaBridge is not quite the fastest, OOLua and sol2 outperforms LuaBridge in some tests, but they are also bigger and slower to compile.</p>
  </blockquote>
  <p>So, why sol2 is slower in my benchmarks then?</p>
  <p><strong>Sol2 benchmark:</strong></p>
  <pre><code>Performing Sol3 Benchmark:
  Time elapsed (Increment (Lua)): 225.012ms
  Time elapsed (Increment (C++)): 210.341ms
  
  Time elapsed (String Argument (Lua)): 400.203ms
  Time elapsed (String Argument (C++)): 241.732ms
  
  Time elapsed (String Const Argument (Lua)): 405.579ms
  Time elapsed (String Const Argument (C++)): 267.502ms
  
  Time elapsed (String View Argument (Lua)): 321.18ms
  Time elapsed (String View Argument (C++)): 258.553ms
  
  Time elapsed (String Char Argument (Lua)): 311.116ms
  Time elapsed (String Char Argument (C++)): 244.752ms
  
  Time elapsed (String Iterator (Lua)): 561.75ms
  Time elapsed (String Iterator (C++)): 188.024ms
  
  Time elapsed (String Const Iterator (Lua)): 555.881ms
  Time elapsed (String Const Iterator (C++)): 215.2ms
  
  Time elapsed (String View Iterator (Lua)): 462.316ms
  Time elapsed (String View Iterator (C++)): 205.954ms
  
  Time elapsed (String Char Iterator (Lua)): 456.837ms
  Time elapsed (String Char Iterator (C++)): 197.267ms
  
  Time elapsed (String Internal Iterator (Lua)): 28.6687ms
  
  Time elapsed (Class passing (Lua)): 491.857ms
  Time elapsed (Class Passing (C++)): 188.96ms
  
  Time elapsed (Class Getting (Lua)): 444.842ms
  Time elapsed (Class Getting (C++)): 87.885ms
  
  Time elapsed (Class method call (Base Class)): 1018.63ms
  Time elapsed (Class method call (Derived Overwritten Class)): 950.832ms
  Time elapsed (Class method call (Derived Not Overwritten Class)): 1672.24ms
  
  Time elapsed (Class field access (Base Class)): 837.028ms
  Time elapsed (Class field access (Derived Class)): 1512.29ms
  </code></pre>
  <p><strong>LuaBridge3 benchmark:</strong></p>
  <pre><code>Performing LuaBridge3 Benchmark:
  Time elapsed (Increment (Lua)): 85.4452ms
  Time elapsed (Increment (C++)): 685.158ms
  
  Time elapsed (String Argument (Lua)): 187.733ms
  Time elapsed (String Argument (C++)): 711.398ms
  
  Time elapsed (String Const Argument (Lua)): 191.785ms
  Time elapsed (String Const Argument (C++)): 740.246ms
  
  Time elapsed (String View Argument (Lua)): 149.068ms
  Time elapsed (String View Argument (C++)): 725.589ms
  
  Time elapsed (String Char Argument (Lua)): 118.564ms
  Time elapsed (String Char Argument (C++)): 718.35ms
  
  Time elapsed (String Iterator (Lua)): 255.276ms
  Time elapsed (String Iterator (C++)): 728.269ms
  
  Time elapsed (String Const Iterator (Lua)): 257.562ms
  Time elapsed (String Const Iterator (C++)): 756.581ms
  
  Time elapsed (String View Iterator (Lua)): 194.296ms
  Time elapsed (String View Iterator (C++)): 738.581ms
  
  Time elapsed (String Char Iterator (Lua)): 170.795ms
  Time elapsed (String Char Iterator (C++)): 737.091ms
  
  Time elapsed (String Internal Iterator (Lua)): 5.10969ms
  
  Time elapsed (Class passing (Lua)): 141.677ms
  Time elapsed (Class Passing (C++)): 489.28ms
  
  Time elapsed (Class Getting (Lua)): 205.569ms
  Time elapsed (Class Getting (C++)): 507.022ms
  
  Time elapsed (Class method call (Base Class)): 154.02ms
  Time elapsed (Class method call (Derived Overwritten Class)): 155.294ms
  Time elapsed (Class method call (Derived Not Overwritten Class)): 248.309ms
  
  Time elapsed (Class field access (Base Class)): 181.451ms
  Time elapsed (Class field access (Derived Class)): 283.496ms
  </code></pre>
  <p>UPD:<br />
  <strong>Sol2 benchmark (with -O3 flag):</strong></p>
  <pre><code>Performing Sol3 Benchmark:
  Time elapsed (Increment (Lua)): 32.6984ms
  Time elapsed (Increment (C++)): 56.1082ms
  Time elapsed (String Argument (Lua)): 73.2311ms
  Time elapsed (String Argument (C++)): 155.397ms
  Time elapsed (String Const Argument (Lua)): 69.815ms
  Time elapsed (String Const Argument (C++)): 176.076ms
  Time elapsed (String View Argument (Lua)): 59.6035ms
  Time elapsed (String View Argument (C++)): 158.813ms
  Time elapsed (String Char Argument (Lua)): 53.9835ms
  Time elapsed (String Char Argument (C++)): 194.122ms
  Time elapsed (String Iterator (Lua)): 116.469ms
  Time elapsed (String Iterator (C++)): 88.9511ms
  Time elapsed (String Const Iterator (Lua)): 114.828ms
  Time elapsed (String Const Iterator (C++)): 99.197ms
  Time elapsed (String View Iterator (Lua)): 85.6064ms
  Time elapsed (String View Iterator (C++)): 91.3165ms
  Time elapsed (String Char Iterator (Lua)): 109.081ms
  Time elapsed (String Char Iterator (C++)): 123.287ms
  Time elapsed (String Internal Iterator (Lua)): 30.3189ms
  Time elapsed (Class passing (Lua)): 155.851ms
  Time elapsed (Class Passing (C++)): 88.1614ms
  Time elapsed (Class Getting (Lua)): 122.943ms
  Time elapsed (Class Getting (C++)): 42.5303ms
  Time elapsed (Class method call (Base Class)): 261.55ms
  Time elapsed (Class method call (Derived Overwritten Class)): 201.069ms
  Time elapsed (Class method call (Derived Not Overwritten Class)): 473.373ms
  Time elapsed (Class field access (Base Class)): 214.91ms
  Time elapsed (Class field access (Derived Class)): 429.851ms
  </code></pre>
  <p><strong>LuaBridge3 benchmark (with -O3 flag):</strong></p>
  <pre><code>Performing LuaBridge3 Benchmark:
  Time elapsed (Increment (Lua)): 24.6991ms
  Time elapsed (Increment (C++)): 169.714ms
  Time elapsed (String Argument (Lua)): 56.6672ms
  Time elapsed (String Argument (C++)): 160.134ms
  Time elapsed (String Const Argument (Lua)): 59.1771ms
  Time elapsed (String Const Argument (C++)): 183.209ms
  Time elapsed (String View Argument (Lua)): 29.8749ms
  Time elapsed (String View Argument (C++)): 164.018ms
  Time elapsed (String Char Argument (Lua)): 29.6969ms
  Time elapsed (String Char Argument (C++)): 168.75ms
  Time elapsed (String Iterator (Lua)): 85.9382ms
  Time elapsed (String Iterator (C++)): 152.362ms
  Time elapsed (String Const Iterator (Lua)): 83.0993ms
  Time elapsed (String Const Iterator (C++)): 178.119ms
  Time elapsed (String View Iterator (Lua)): 52.2461ms
  Time elapsed (String View Iterator (C++)): 153.509ms
  Time elapsed (String Char Iterator (Lua)): 51.528ms
  Time elapsed (String Char Iterator (C++)): 163.818ms
  Time elapsed (String Internal Iterator (Lua)): 6.12704ms
  Time elapsed (Class passing (Lua)): 73.1719ms
  Time elapsed (Class Passing (C++)): 157.952ms
  Time elapsed (Class Getting (Lua)): 125.278ms
  Time elapsed (Class Getting (C++)): 119.256ms
  Time elapsed (Class method call (Base Class)): 107.476ms
  Time elapsed (Class method call (Derived Overwritten Class)): 111.158ms
  Time elapsed (Class method call (Derived Not Overwritten Class)): 196.297ms
  Time elapsed (Class field access (Base Class)): 143.778ms
  Time elapsed (Class field access (Derived Class)): 234.974ms
  </code></pre>