| 1 |
<!DOCTYPE html> |
| 2 |
|
| 3 |
<html> |
| 4 |
|
| 5 |
<head> |
| 6 |
|
| 7 |
<meta charset="utf-8" /> |
| 8 |
<meta name="generator" content="pandoc" /> |
| 9 |
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" /> |
| 10 |
|
| 11 |
<meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
<title>Performance</title> |
| 16 |
|
| 17 |
<script>// Pandoc 2.9 adds attributes on both header and div. We remove the former (to |
| 18 |
// be compatible with the behavior of Pandoc < 2.8). |
| 19 |
document.addEventListener('DOMContentLoaded', function(e) { |
| 20 |
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); |
| 21 |
var i, h, a; |
| 22 |
for (i = 0; i < hs.length; i++) { |
| 23 |
h = hs[i]; |
| 24 |
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 |
| 25 |
a = h.attributes; |
| 26 |
while (a.length > 0) h.removeAttribute(a[0].name); |
| 27 |
} |
| 28 |
}); |
| 29 |
</script> |
| 30 |
|
| 31 |
<style type="text/css"> |
| 32 |
code{white-space: pre-wrap;} |
| 33 |
span.smallcaps{font-variant: small-caps;} |
| 34 |
span.underline{text-decoration: underline;} |
| 35 |
div.column{display: inline-block; vertical-align: top; width: 50%;} |
| 36 |
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} |
| 37 |
ul.task-list{list-style: none;} |
| 38 |
</style> |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
<style type="text/css"> |
| 43 |
code { |
| 44 |
white-space: pre; |
| 45 |
} |
| 46 |
.sourceCode { |
| 47 |
overflow: visible; |
| 48 |
} |
| 49 |
</style> |
| 50 |
<style type="text/css" data-origin="pandoc"> |
| 51 |
html { -webkit-text-size-adjust: 100%; } |
| 52 |
pre > code.sourceCode { white-space: pre; position: relative; } |
| 53 |
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } |
| 54 |
pre > code.sourceCode > span:empty { height: 1.2em; } |
| 55 |
.sourceCode { overflow: visible; } |
| 56 |
code.sourceCode > span { color: inherit; text-decoration: inherit; } |
| 57 |
div.sourceCode { margin: 1em 0; } |
| 58 |
pre.sourceCode { margin: 0; } |
| 59 |
@media screen { |
| 60 |
div.sourceCode { overflow: auto; } |
| 61 |
} |
| 62 |
@media print { |
| 63 |
pre > code.sourceCode { white-space: pre-wrap; } |
| 64 |
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } |
| 65 |
} |
| 66 |
pre.numberSource code |
| 67 |
{ counter-reset: source-line 0; } |
| 68 |
pre.numberSource code > span |
| 69 |
{ position: relative; left: -4em; counter-increment: source-line; } |
| 70 |
pre.numberSource code > span > a:first-child::before |
| 71 |
{ content: counter(source-line); |
| 72 |
position: relative; left: -1em; text-align: right; vertical-align: baseline; |
| 73 |
border: none; display: inline-block; |
| 74 |
-webkit-touch-callout: none; -webkit-user-select: none; |
| 75 |
-khtml-user-select: none; -moz-user-select: none; |
| 76 |
-ms-user-select: none; user-select: none; |
| 77 |
padding: 0 4px; width: 4em; |
| 78 |
color: #aaaaaa; |
| 79 |
} |
| 80 |
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } |
| 81 |
div.sourceCode |
| 82 |
{ } |
| 83 |
@media screen { |
| 84 |
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } |
| 85 |
} |
| 86 |
code span.al { color: #ff0000; font-weight: bold; } |
| 87 |
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } |
| 88 |
code span.at { color: #7d9029; } |
| 89 |
code span.bn { color: #40a070; } |
| 90 |
code span.bu { color: #008000; } |
| 91 |
code span.cf { color: #007020; font-weight: bold; } |
| 92 |
code span.ch { color: #4070a0; } |
| 93 |
code span.cn { color: #880000; } |
| 94 |
code span.co { color: #60a0b0; font-style: italic; } |
| 95 |
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } |
| 96 |
code span.do { color: #ba2121; font-style: italic; } |
| 97 |
code span.dt { color: #902000; } |
| 98 |
code span.dv { color: #40a070; } |
| 99 |
code span.er { color: #ff0000; font-weight: bold; } |
| 100 |
code span.ex { } |
| 101 |
code span.fl { color: #40a070; } |
| 102 |
code span.fu { color: #06287e; } |
| 103 |
code span.im { color: #008000; font-weight: bold; } |
| 104 |
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } |
| 105 |
code span.kw { color: #007020; font-weight: bold; } |
| 106 |
code span.op { color: #666666; } |
| 107 |
code span.ot { color: #007020; } |
| 108 |
code span.pp { color: #bc7a00; } |
| 109 |
code span.sc { color: #4070a0; } |
| 110 |
code span.ss { color: #bb6688; } |
| 111 |
code span.st { color: #4070a0; } |
| 112 |
code span.va { color: #19177c; } |
| 113 |
code span.vs { color: #4070a0; } |
| 114 |
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } |
| 115 |
</style> |
| 116 |
<script> |
| 117 |
// apply pandoc div.sourceCode style to pre.sourceCode instead |
| 118 |
(function() { |
| 119 |
var sheets = document.styleSheets; |
| 120 |
for (var i = 0; i < sheets.length; i++) { |
| 121 |
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue; |
| 122 |
try { var rules = sheets[i].cssRules; } catch (e) { continue; } |
| 123 |
var j = 0; |
| 124 |
while (j < rules.length) { |
| 125 |
var rule = rules[j]; |
| 126 |
// check if there is a div.sourceCode rule |
| 127 |
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") { |
| 128 |
j++; |
| 129 |
continue; |
| 130 |
} |
| 131 |
var style = rule.style.cssText; |
| 132 |
// check if color or background-color is set |
| 133 |
if (rule.style.color === '' && rule.style.backgroundColor === '') { |
| 134 |
j++; |
| 135 |
continue; |
| 136 |
} |
| 137 |
// replace div.sourceCode by a pre.sourceCode rule |
| 138 |
sheets[i].deleteRule(j); |
| 139 |
sheets[i].insertRule('pre.sourceCode{' + style + '}', j); |
| 140 |
} |
| 141 |
} |
| 142 |
})(); |
| 143 |
</script> |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
<style type="text/css">body { |
| 149 |
background-color: #fff; |
| 150 |
margin: 1em auto; |
| 151 |
max-width: 700px; |
| 152 |
overflow: visible; |
| 153 |
padding-left: 2em; |
| 154 |
padding-right: 2em; |
| 155 |
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; |
| 156 |
font-size: 14px; |
| 157 |
line-height: 1.35; |
| 158 |
} |
| 159 |
#TOC { |
| 160 |
clear: both; |
| 161 |
margin: 0 0 10px 10px; |
| 162 |
padding: 4px; |
| 163 |
width: 400px; |
| 164 |
border: 1px solid #CCCCCC; |
| 165 |
border-radius: 5px; |
| 166 |
background-color: #f6f6f6; |
| 167 |
font-size: 13px; |
| 168 |
line-height: 1.3; |
| 169 |
} |
| 170 |
#TOC .toctitle { |
| 171 |
font-weight: bold; |
| 172 |
font-size: 15px; |
| 173 |
margin-left: 5px; |
| 174 |
} |
| 175 |
#TOC ul { |
| 176 |
padding-left: 40px; |
| 177 |
margin-left: -1.5em; |
| 178 |
margin-top: 5px; |
| 179 |
margin-bottom: 5px; |
| 180 |
} |
| 181 |
#TOC ul ul { |
| 182 |
margin-left: -2em; |
| 183 |
} |
| 184 |
#TOC li { |
| 185 |
line-height: 16px; |
| 186 |
} |
| 187 |
table { |
| 188 |
margin: 1em auto; |
| 189 |
border-width: 1px; |
| 190 |
border-color: #DDDDDD; |
| 191 |
border-style: outset; |
| 192 |
border-collapse: collapse; |
| 193 |
} |
| 194 |
table th { |
| 195 |
border-width: 2px; |
| 196 |
padding: 5px; |
| 197 |
border-style: inset; |
| 198 |
} |
| 199 |
table td { |
| 200 |
border-width: 1px; |
| 201 |
border-style: inset; |
| 202 |
line-height: 18px; |
| 203 |
padding: 5px 5px; |
| 204 |
} |
| 205 |
table, table th, table td { |
| 206 |
border-left-style: none; |
| 207 |
border-right-style: none; |
| 208 |
} |
| 209 |
table thead, table tr.even { |
| 210 |
background-color: #f7f7f7; |
| 211 |
} |
| 212 |
p { |
| 213 |
margin: 0.5em 0; |
| 214 |
} |
| 215 |
blockquote { |
| 216 |
background-color: #f6f6f6; |
| 217 |
padding: 0.25em 0.75em; |
| 218 |
} |
| 219 |
hr { |
| 220 |
border-style: solid; |
| 221 |
border: none; |
| 222 |
border-top: 1px solid #777; |
| 223 |
margin: 28px 0; |
| 224 |
} |
| 225 |
dl { |
| 226 |
margin-left: 0; |
| 227 |
} |
| 228 |
dl dd { |
| 229 |
margin-bottom: 13px; |
| 230 |
margin-left: 13px; |
| 231 |
} |
| 232 |
dl dt { |
| 233 |
font-weight: bold; |
| 234 |
} |
| 235 |
ul { |
| 236 |
margin-top: 0; |
| 237 |
} |
| 238 |
ul li { |
| 239 |
list-style: circle outside; |
| 240 |
} |
| 241 |
ul ul { |
| 242 |
margin-bottom: 0; |
| 243 |
} |
| 244 |
pre, code { |
| 245 |
background-color: #f7f7f7; |
| 246 |
border-radius: 3px; |
| 247 |
color: #333; |
| 248 |
white-space: pre-wrap; |
| 249 |
} |
| 250 |
pre { |
| 251 |
border-radius: 3px; |
| 252 |
margin: 5px 0px 10px 0px; |
| 253 |
padding: 10px; |
| 254 |
} |
| 255 |
pre:not([class]) { |
| 256 |
background-color: #f7f7f7; |
| 257 |
} |
| 258 |
code { |
| 259 |
font-family: Consolas, Monaco, 'Courier New', monospace; |
| 260 |
font-size: 85%; |
| 261 |
} |
| 262 |
p > code, li > code { |
| 263 |
padding: 2px 0px; |
| 264 |
} |
| 265 |
div.figure { |
| 266 |
text-align: center; |
| 267 |
} |
| 268 |
img { |
| 269 |
background-color: #FFFFFF; |
| 270 |
padding: 2px; |
| 271 |
border: 1px solid #DDDDDD; |
| 272 |
border-radius: 3px; |
| 273 |
border: 1px solid #CCCCCC; |
| 274 |
margin: 0 5px; |
| 275 |
} |
| 276 |
h1 { |
| 277 |
margin-top: 0; |
| 278 |
font-size: 35px; |
| 279 |
line-height: 40px; |
| 280 |
} |
| 281 |
h2 { |
| 282 |
border-bottom: 4px solid #f7f7f7; |
| 283 |
padding-top: 10px; |
| 284 |
padding-bottom: 2px; |
| 285 |
font-size: 145%; |
| 286 |
} |
| 287 |
h3 { |
| 288 |
border-bottom: 2px solid #f7f7f7; |
| 289 |
padding-top: 10px; |
| 290 |
font-size: 120%; |
| 291 |
} |
| 292 |
h4 { |
| 293 |
border-bottom: 1px solid #f7f7f7; |
| 294 |
margin-left: 8px; |
| 295 |
font-size: 105%; |
| 296 |
} |
| 297 |
h5, h6 { |
| 298 |
border-bottom: 1px solid #ccc; |
| 299 |
font-size: 105%; |
| 300 |
} |
| 301 |
a { |
| 302 |
color: #0033dd; |
| 303 |
text-decoration: none; |
| 304 |
} |
| 305 |
a:hover { |
| 306 |
color: #6666ff; } |
| 307 |
a:visited { |
| 308 |
color: #800080; } |
| 309 |
a:visited:hover { |
| 310 |
color: #BB00BB; } |
| 311 |
a[href^="http:"] { |
| 312 |
text-decoration: underline; } |
| 313 |
a[href^="https:"] { |
| 314 |
text-decoration: underline; } |
| 315 |
|
| 316 |
code > span.kw { color: #555; font-weight: bold; } |
| 317 |
code > span.dt { color: #902000; } |
| 318 |
code > span.dv { color: #40a070; } |
| 319 |
code > span.bn { color: #d14; } |
| 320 |
code > span.fl { color: #d14; } |
| 321 |
code > span.ch { color: #d14; } |
| 322 |
code > span.st { color: #d14; } |
| 323 |
code > span.co { color: #888888; font-style: italic; } |
| 324 |
code > span.ot { color: #007020; } |
| 325 |
code > span.al { color: #ff0000; font-weight: bold; } |
| 326 |
code > span.fu { color: #900; font-weight: bold; } |
| 327 |
code > span.er { color: #a61717; background-color: #e3d2d2; } |
| 328 |
</style> |
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
</head> |
| 334 |
|
| 335 |
<body> |
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
<h1 class="title toc-ignore">Performance</h1> |
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="fu">library</span>(S7)</span></code></pre></div> |
| 345 |
<p>The dispatch performance should be roughly on par with S3 and S4, |
| 346 |
though as this is implemented in a package there is some overhead due to |
| 347 |
<code>.Call</code> vs <code>.Primitive</code>.</p> |
| 348 |
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" tabindex="-1"></a>Text <span class="ot"><-</span> <span class="fu">new_class</span>(<span class="st">"Text"</span>, <span class="at">parent =</span> class_character)</span> |
| 349 |
<span id="cb2-2"><a href="#cb2-2" tabindex="-1"></a>Number <span class="ot"><-</span> <span class="fu">new_class</span>(<span class="st">"Number"</span>, <span class="at">parent =</span> class_double)</span> |
| 350 |
<span id="cb2-3"><a href="#cb2-3" tabindex="-1"></a></span> |
| 351 |
<span id="cb2-4"><a href="#cb2-4" tabindex="-1"></a>x <span class="ot"><-</span> <span class="fu">Text</span>(<span class="st">"hi"</span>)</span> |
| 352 |
<span id="cb2-5"><a href="#cb2-5" tabindex="-1"></a>y <span class="ot"><-</span> <span class="fu">Number</span>(<span class="dv">1</span>)</span> |
| 353 |
<span id="cb2-6"><a href="#cb2-6" tabindex="-1"></a></span> |
| 354 |
<span id="cb2-7"><a href="#cb2-7" tabindex="-1"></a>foo_S7 <span class="ot"><-</span> <span class="fu">new_generic</span>(<span class="st">"foo_S7"</span>, <span class="st">"x"</span>)</span> |
| 355 |
<span id="cb2-8"><a href="#cb2-8" tabindex="-1"></a><span class="fu">method</span>(foo_S7, Text) <span class="ot"><-</span> <span class="cf">function</span>(x, ...) <span class="fu">paste0</span>(x, <span class="st">"-foo"</span>)</span> |
| 356 |
<span id="cb2-9"><a href="#cb2-9" tabindex="-1"></a></span> |
| 357 |
<span id="cb2-10"><a href="#cb2-10" tabindex="-1"></a>foo_S3 <span class="ot"><-</span> <span class="cf">function</span>(x, ...) {</span> |
| 358 |
<span id="cb2-11"><a href="#cb2-11" tabindex="-1"></a> <span class="fu">UseMethod</span>(<span class="st">"foo_S3"</span>)</span> |
| 359 |
<span id="cb2-12"><a href="#cb2-12" tabindex="-1"></a>}</span> |
| 360 |
<span id="cb2-13"><a href="#cb2-13" tabindex="-1"></a></span> |
| 361 |
<span id="cb2-14"><a href="#cb2-14" tabindex="-1"></a>foo_S3.Text <span class="ot"><-</span> <span class="cf">function</span>(x, ...) {</span> |
| 362 |
<span id="cb2-15"><a href="#cb2-15" tabindex="-1"></a> <span class="fu">paste0</span>(x, <span class="st">"-foo"</span>)</span> |
| 363 |
<span id="cb2-16"><a href="#cb2-16" tabindex="-1"></a>}</span> |
| 364 |
<span id="cb2-17"><a href="#cb2-17" tabindex="-1"></a></span> |
| 365 |
<span id="cb2-18"><a href="#cb2-18" tabindex="-1"></a><span class="fu">library</span>(methods)</span> |
| 366 |
<span id="cb2-19"><a href="#cb2-19" tabindex="-1"></a><span class="fu">setOldClass</span>(<span class="fu">c</span>(<span class="st">"Number"</span>, <span class="st">"numeric"</span>, <span class="st">"S7_object"</span>))</span> |
| 367 |
<span id="cb2-20"><a href="#cb2-20" tabindex="-1"></a><span class="fu">setOldClass</span>(<span class="fu">c</span>(<span class="st">"Text"</span>, <span class="st">"character"</span>, <span class="st">"S7_object"</span>))</span> |
| 368 |
<span id="cb2-21"><a href="#cb2-21" tabindex="-1"></a></span> |
| 369 |
<span id="cb2-22"><a href="#cb2-22" tabindex="-1"></a><span class="fu">setGeneric</span>(<span class="st">"foo_S4"</span>, <span class="cf">function</span>(x, ...) <span class="fu">standardGeneric</span>(<span class="st">"foo_S4"</span>))</span> |
| 370 |
<span id="cb2-23"><a href="#cb2-23" tabindex="-1"></a><span class="co">#> [1] "foo_S4"</span></span> |
| 371 |
<span id="cb2-24"><a href="#cb2-24" tabindex="-1"></a><span class="fu">setMethod</span>(<span class="st">"foo_S4"</span>, <span class="fu">c</span>(<span class="st">"Text"</span>), <span class="cf">function</span>(x, ...) <span class="fu">paste0</span>(x, <span class="st">"-foo"</span>))</span> |
| 372 |
<span id="cb2-25"><a href="#cb2-25" tabindex="-1"></a></span> |
| 373 |
<span id="cb2-26"><a href="#cb2-26" tabindex="-1"></a><span class="co"># Measure performance of single dispatch</span></span> |
| 374 |
<span id="cb2-27"><a href="#cb2-27" tabindex="-1"></a>bench<span class="sc">::</span><span class="fu">mark</span>(<span class="fu">foo_S7</span>(x), <span class="fu">foo_S3</span>(x), <span class="fu">foo_S4</span>(x))</span> |
| 375 |
<span id="cb2-28"><a href="#cb2-28" tabindex="-1"></a><span class="co">#> # A tibble: 3 × 6</span></span> |
| 376 |
<span id="cb2-29"><a href="#cb2-29" tabindex="-1"></a><span class="co">#> expression min median `itr/sec` mem_alloc `gc/sec`</span></span> |
| 377 |
<span id="cb2-30"><a href="#cb2-30" tabindex="-1"></a><span class="co">#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl></span></span> |
| 378 |
<span id="cb2-31"><a href="#cb2-31" tabindex="-1"></a><span class="co">#> 1 foo_S7(x) 2.42µs 2.91µs 330701. 0B 99.2</span></span> |
| 379 |
<span id="cb2-32"><a href="#cb2-32" tabindex="-1"></a><span class="co">#> 2 foo_S3(x) 861.01ns 1.07µs 862274. 0B 86.2</span></span> |
| 380 |
<span id="cb2-33"><a href="#cb2-33" tabindex="-1"></a><span class="co">#> 3 foo_S4(x) 860.98ns 1.15µs 843830. 0B 84.4</span></span> |
| 381 |
<span id="cb2-34"><a href="#cb2-34" tabindex="-1"></a></span> |
| 382 |
<span id="cb2-35"><a href="#cb2-35" tabindex="-1"></a>bar_S7 <span class="ot"><-</span> <span class="fu">new_generic</span>(<span class="st">"bar_S7"</span>, <span class="fu">c</span>(<span class="st">"x"</span>, <span class="st">"y"</span>))</span> |
| 383 |
<span id="cb2-36"><a href="#cb2-36" tabindex="-1"></a><span class="fu">method</span>(bar_S7, <span class="fu">list</span>(Text, Number)) <span class="ot"><-</span> <span class="cf">function</span>(x, y, ...) <span class="fu">paste0</span>(x, <span class="st">"-"</span>, y, <span class="st">"-bar"</span>)</span> |
| 384 |
<span id="cb2-37"><a href="#cb2-37" tabindex="-1"></a></span> |
| 385 |
<span id="cb2-38"><a href="#cb2-38" tabindex="-1"></a><span class="fu">setGeneric</span>(<span class="st">"bar_S4"</span>, <span class="cf">function</span>(x, y, ...) <span class="fu">standardGeneric</span>(<span class="st">"bar_S4"</span>))</span> |
| 386 |
<span id="cb2-39"><a href="#cb2-39" tabindex="-1"></a><span class="co">#> [1] "bar_S4"</span></span> |
| 387 |
<span id="cb2-40"><a href="#cb2-40" tabindex="-1"></a><span class="fu">setMethod</span>(<span class="st">"bar_S4"</span>, <span class="fu">c</span>(<span class="st">"Text"</span>, <span class="st">"Number"</span>), <span class="cf">function</span>(x, y, ...) <span class="fu">paste0</span>(x, <span class="st">"-"</span>, y, <span class="st">"-bar"</span>))</span> |
| 388 |
<span id="cb2-41"><a href="#cb2-41" tabindex="-1"></a></span> |
| 389 |
<span id="cb2-42"><a href="#cb2-42" tabindex="-1"></a><span class="co"># Measure performance of double dispatch</span></span> |
| 390 |
<span id="cb2-43"><a href="#cb2-43" tabindex="-1"></a>bench<span class="sc">::</span><span class="fu">mark</span>(<span class="fu">bar_S7</span>(x, y), <span class="fu">bar_S4</span>(x, y))</span> |
| 391 |
<span id="cb2-44"><a href="#cb2-44" tabindex="-1"></a><span class="co">#> # A tibble: 2 × 6</span></span> |
| 392 |
<span id="cb2-45"><a href="#cb2-45" tabindex="-1"></a><span class="co">#> expression min median `itr/sec` mem_alloc `gc/sec`</span></span> |
| 393 |
<span id="cb2-46"><a href="#cb2-46" tabindex="-1"></a><span class="co">#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl></span></span> |
| 394 |
<span id="cb2-47"><a href="#cb2-47" tabindex="-1"></a><span class="co">#> 1 bar_S7(x, y) 4.55µs 5.66µs 168263. 0B 67.3</span></span> |
| 395 |
<span id="cb2-48"><a href="#cb2-48" tabindex="-1"></a><span class="co">#> 2 bar_S4(x, y) 2.46µs 2.99µs 330169. 0B 66.0</span></span></code></pre></div> |
| 396 |
<p>A potential optimization is caching based on the class names, but |
| 397 |
lookup should be fast without this.</p> |
| 398 |
<p>The following benchmark generates a class hierarchy of different |
| 399 |
levels and lengths of class names and compares the time to dispatch on |
| 400 |
the first class in the hierarchy vs the time to dispatch on the last |
| 401 |
class.</p> |
| 402 |
<p>We find that even in very extreme cases (e.g. 100 deep hierarchy 100 |
| 403 |
of character class names) the overhead is reasonable, and for more |
| 404 |
reasonable cases (e.g. 10 deep hierarchy of 15 character class names) |
| 405 |
the overhead is basically negligible.</p> |
| 406 |
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" tabindex="-1"></a><span class="fu">library</span>(S7)</span> |
| 407 |
<span id="cb3-2"><a href="#cb3-2" tabindex="-1"></a></span> |
| 408 |
<span id="cb3-3"><a href="#cb3-3" tabindex="-1"></a>gen_character <span class="ot"><-</span> <span class="cf">function</span> (n, <span class="at">min =</span> <span class="dv">5</span>, <span class="at">max =</span> <span class="dv">25</span>, <span class="at">values =</span> <span class="fu">c</span>(letters, LETTERS, <span class="dv">0</span><span class="sc">:</span><span class="dv">9</span>)) {</span> |
| 409 |
<span id="cb3-4"><a href="#cb3-4" tabindex="-1"></a> lengths <span class="ot"><-</span> <span class="fu">sample</span>(min<span class="sc">:</span>max, <span class="at">replace =</span> <span class="cn">TRUE</span>, <span class="at">size =</span> n)</span> |
| 410 |
<span id="cb3-5"><a href="#cb3-5" tabindex="-1"></a> values <span class="ot"><-</span> <span class="fu">sample</span>(values, <span class="fu">sum</span>(lengths), <span class="at">replace =</span> <span class="cn">TRUE</span>)</span> |
| 411 |
<span id="cb3-6"><a href="#cb3-6" tabindex="-1"></a> starts <span class="ot"><-</span> <span class="fu">c</span>(<span class="dv">1</span>, <span class="fu">cumsum</span>(lengths)[<span class="sc">-</span>n] <span class="sc">+</span> <span class="dv">1</span>)</span> |
| 412 |
<span id="cb3-7"><a href="#cb3-7" tabindex="-1"></a> ends <span class="ot"><-</span> <span class="fu">cumsum</span>(lengths)</span> |
| 413 |
<span id="cb3-8"><a href="#cb3-8" tabindex="-1"></a> <span class="fu">mapply</span>(<span class="cf">function</span>(start, end) <span class="fu">paste0</span>(values[start<span class="sc">:</span>end], <span class="at">collapse=</span><span class="st">""</span>), starts, ends)</span> |
| 414 |
<span id="cb3-9"><a href="#cb3-9" tabindex="-1"></a>}</span> |
| 415 |
<span id="cb3-10"><a href="#cb3-10" tabindex="-1"></a></span> |
| 416 |
<span id="cb3-11"><a href="#cb3-11" tabindex="-1"></a>bench<span class="sc">::</span><span class="fu">press</span>(</span> |
| 417 |
<span id="cb3-12"><a href="#cb3-12" tabindex="-1"></a> <span class="at">num_classes =</span> <span class="fu">c</span>(<span class="dv">3</span>, <span class="dv">5</span>, <span class="dv">10</span>, <span class="dv">50</span>, <span class="dv">100</span>),</span> |
| 418 |
<span id="cb3-13"><a href="#cb3-13" tabindex="-1"></a> <span class="at">class_nchar =</span> <span class="fu">c</span>(<span class="dv">15</span>, <span class="dv">100</span>),</span> |
| 419 |
<span id="cb3-14"><a href="#cb3-14" tabindex="-1"></a> {</span> |
| 420 |
<span id="cb3-15"><a href="#cb3-15" tabindex="-1"></a> <span class="co"># Construct a class hierarchy with that number of classes</span></span> |
| 421 |
<span id="cb3-16"><a href="#cb3-16" tabindex="-1"></a> Text <span class="ot"><-</span> <span class="fu">new_class</span>(<span class="st">"Text"</span>, <span class="at">parent =</span> class_character)</span> |
| 422 |
<span id="cb3-17"><a href="#cb3-17" tabindex="-1"></a> parent <span class="ot"><-</span> Text</span> |
| 423 |
<span id="cb3-18"><a href="#cb3-18" tabindex="-1"></a> classes <span class="ot"><-</span> <span class="fu">gen_character</span>(num_classes, <span class="at">min =</span> class_nchar, <span class="at">max =</span> class_nchar)</span> |
| 424 |
<span id="cb3-19"><a href="#cb3-19" tabindex="-1"></a> env <span class="ot"><-</span> <span class="fu">new.env</span>()</span> |
| 425 |
<span id="cb3-20"><a href="#cb3-20" tabindex="-1"></a> <span class="cf">for</span> (x <span class="cf">in</span> classes) {</span> |
| 426 |
<span id="cb3-21"><a href="#cb3-21" tabindex="-1"></a> <span class="fu">assign</span>(x, <span class="fu">new_class</span>(x, <span class="at">parent =</span> parent), env)</span> |
| 427 |
<span id="cb3-22"><a href="#cb3-22" tabindex="-1"></a> parent <span class="ot"><-</span> <span class="fu">get</span>(x, env)</span> |
| 428 |
<span id="cb3-23"><a href="#cb3-23" tabindex="-1"></a> }</span> |
| 429 |
<span id="cb3-24"><a href="#cb3-24" tabindex="-1"></a></span> |
| 430 |
<span id="cb3-25"><a href="#cb3-25" tabindex="-1"></a> <span class="co"># Get the last defined class</span></span> |
| 431 |
<span id="cb3-26"><a href="#cb3-26" tabindex="-1"></a> cls <span class="ot"><-</span> parent</span> |
| 432 |
<span id="cb3-27"><a href="#cb3-27" tabindex="-1"></a></span> |
| 433 |
<span id="cb3-28"><a href="#cb3-28" tabindex="-1"></a> <span class="co"># Construct an object of that class</span></span> |
| 434 |
<span id="cb3-29"><a href="#cb3-29" tabindex="-1"></a> x <span class="ot"><-</span> <span class="fu">do.call</span>(cls, <span class="fu">list</span>(<span class="st">"hi"</span>))</span> |
| 435 |
<span id="cb3-30"><a href="#cb3-30" tabindex="-1"></a></span> |
| 436 |
<span id="cb3-31"><a href="#cb3-31" tabindex="-1"></a> <span class="co"># Define a generic and a method for the last class (best case scenario)</span></span> |
| 437 |
<span id="cb3-32"><a href="#cb3-32" tabindex="-1"></a> foo_S7 <span class="ot"><-</span> <span class="fu">new_generic</span>(<span class="st">"foo_S7"</span>, <span class="st">"x"</span>)</span> |
| 438 |
<span id="cb3-33"><a href="#cb3-33" tabindex="-1"></a> <span class="fu">method</span>(foo_S7, cls) <span class="ot"><-</span> <span class="cf">function</span>(x, ...) <span class="fu">paste0</span>(x, <span class="st">"-foo"</span>)</span> |
| 439 |
<span id="cb3-34"><a href="#cb3-34" tabindex="-1"></a></span> |
| 440 |
<span id="cb3-35"><a href="#cb3-35" tabindex="-1"></a> <span class="co"># Define a generic and a method for the first class (worst case scenario)</span></span> |
| 441 |
<span id="cb3-36"><a href="#cb3-36" tabindex="-1"></a> foo2_S7 <span class="ot"><-</span> <span class="fu">new_generic</span>(<span class="st">"foo2_S7"</span>, <span class="st">"x"</span>)</span> |
| 442 |
<span id="cb3-37"><a href="#cb3-37" tabindex="-1"></a> <span class="fu">method</span>(foo2_S7, S7_object) <span class="ot"><-</span> <span class="cf">function</span>(x, ...) <span class="fu">paste0</span>(x, <span class="st">"-foo"</span>)</span> |
| 443 |
<span id="cb3-38"><a href="#cb3-38" tabindex="-1"></a></span> |
| 444 |
<span id="cb3-39"><a href="#cb3-39" tabindex="-1"></a> bench<span class="sc">::</span><span class="fu">mark</span>(</span> |
| 445 |
<span id="cb3-40"><a href="#cb3-40" tabindex="-1"></a> <span class="at">best =</span> <span class="fu">foo_S7</span>(x),</span> |
| 446 |
<span id="cb3-41"><a href="#cb3-41" tabindex="-1"></a> <span class="at">worst =</span> <span class="fu">foo2_S7</span>(x)</span> |
| 447 |
<span id="cb3-42"><a href="#cb3-42" tabindex="-1"></a> )</span> |
| 448 |
<span id="cb3-43"><a href="#cb3-43" tabindex="-1"></a> }</span> |
| 449 |
<span id="cb3-44"><a href="#cb3-44" tabindex="-1"></a>)</span> |
| 450 |
<span id="cb3-45"><a href="#cb3-45" tabindex="-1"></a><span class="co">#> # A tibble: 20 × 8</span></span> |
| 451 |
<span id="cb3-46"><a href="#cb3-46" tabindex="-1"></a><span class="co">#> expression num_classes class_nchar min median `itr/sec` mem_alloc `gc/sec`</span></span> |
| 452 |
<span id="cb3-47"><a href="#cb3-47" tabindex="-1"></a><span class="co">#> <bch:expr> <dbl> <dbl> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl></span></span> |
| 453 |
<span id="cb3-48"><a href="#cb3-48" tabindex="-1"></a><span class="co">#> 1 best 3 15 2.46µs 3.03µs 320538. 0B 96.2</span></span> |
| 454 |
<span id="cb3-49"><a href="#cb3-49" tabindex="-1"></a><span class="co">#> 2 worst 3 15 2.54µs 3.03µs 326714. 0B 98.0</span></span> |
| 455 |
<span id="cb3-50"><a href="#cb3-50" tabindex="-1"></a><span class="co">#> 3 best 5 15 2.38µs 2.95µs 336761. 0B 67.4</span></span> |
| 456 |
<span id="cb3-51"><a href="#cb3-51" tabindex="-1"></a><span class="co">#> 4 worst 5 15 2.58µs 3.08µs 319673. 0B 95.9</span></span> |
| 457 |
<span id="cb3-52"><a href="#cb3-52" tabindex="-1"></a><span class="co">#> 5 best 10 15 2.46µs 2.95µs 333903. 0B 100. </span></span> |
| 458 |
<span id="cb3-53"><a href="#cb3-53" tabindex="-1"></a><span class="co">#> 6 worst 10 15 2.67µs 3.2µs 305966. 0B 91.8</span></span> |
| 459 |
<span id="cb3-54"><a href="#cb3-54" tabindex="-1"></a><span class="co">#> 7 best 50 15 2.71µs 3.2µs 310232. 0B 93.1</span></span> |
| 460 |
<span id="cb3-55"><a href="#cb3-55" tabindex="-1"></a><span class="co">#> 8 worst 50 15 3.57µs 4.22µs 236754. 0B 71.0</span></span> |
| 461 |
<span id="cb3-56"><a href="#cb3-56" tabindex="-1"></a><span class="co">#> 9 best 100 15 2.99µs 3.57µs 277814. 0B 83.4</span></span> |
| 462 |
<span id="cb3-57"><a href="#cb3-57" tabindex="-1"></a><span class="co">#> 10 worst 100 15 4.92µs 5.78µs 171688. 0B 68.7</span></span> |
| 463 |
<span id="cb3-58"><a href="#cb3-58" tabindex="-1"></a><span class="co">#> 11 best 3 100 2.54µs 3.08µs 317960. 0B 95.4</span></span> |
| 464 |
<span id="cb3-59"><a href="#cb3-59" tabindex="-1"></a><span class="co">#> 12 worst 3 100 2.79µs 3.4µs 286052. 0B 85.8</span></span> |
| 465 |
<span id="cb3-60"><a href="#cb3-60" tabindex="-1"></a><span class="co">#> 13 best 5 100 2.54µs 3.08µs 313021. 0B 62.6</span></span> |
| 466 |
<span id="cb3-61"><a href="#cb3-61" tabindex="-1"></a><span class="co">#> 14 worst 5 100 2.79µs 3.32µs 289301. 0B 86.8</span></span> |
| 467 |
<span id="cb3-62"><a href="#cb3-62" tabindex="-1"></a><span class="co">#> 15 best 10 100 2.62µs 3.2µs 305120. 0B 91.6</span></span> |
| 468 |
<span id="cb3-63"><a href="#cb3-63" tabindex="-1"></a><span class="co">#> 16 worst 10 100 3.28µs 3.9µs 254938. 0B 76.5</span></span> |
| 469 |
<span id="cb3-64"><a href="#cb3-64" tabindex="-1"></a><span class="co">#> 17 best 50 100 2.71µs 3.32µs 294308. 0B 88.3</span></span> |
| 470 |
<span id="cb3-65"><a href="#cb3-65" tabindex="-1"></a><span class="co">#> 18 worst 50 100 5.58µs 6.48µs 154093. 0B 46.2</span></span> |
| 471 |
<span id="cb3-66"><a href="#cb3-66" tabindex="-1"></a><span class="co">#> 19 best 100 100 2.99µs 3.57µs 274455. 0B 82.4</span></span> |
| 472 |
<span id="cb3-67"><a href="#cb3-67" tabindex="-1"></a><span class="co">#> 20 worst 100 100 10.09µs 10.62µs 91679. 0B 27.5</span></span></code></pre></div> |
| 473 |
<p>And the same benchmark using double-dispatch</p> |
| 474 |
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" tabindex="-1"></a>bench<span class="sc">::</span><span class="fu">press</span>(</span> |
| 475 |
<span id="cb4-2"><a href="#cb4-2" tabindex="-1"></a> <span class="at">num_classes =</span> <span class="fu">c</span>(<span class="dv">3</span>, <span class="dv">5</span>, <span class="dv">10</span>, <span class="dv">50</span>, <span class="dv">100</span>),</span> |
| 476 |
<span id="cb4-3"><a href="#cb4-3" tabindex="-1"></a> <span class="at">class_nchar =</span> <span class="fu">c</span>(<span class="dv">15</span>, <span class="dv">100</span>),</span> |
| 477 |
<span id="cb4-4"><a href="#cb4-4" tabindex="-1"></a> {</span> |
| 478 |
<span id="cb4-5"><a href="#cb4-5" tabindex="-1"></a> <span class="co"># Construct a class hierarchy with that number of classes</span></span> |
| 479 |
<span id="cb4-6"><a href="#cb4-6" tabindex="-1"></a> Text <span class="ot"><-</span> <span class="fu">new_class</span>(<span class="st">"Text"</span>, <span class="at">parent =</span> class_character)</span> |
| 480 |
<span id="cb4-7"><a href="#cb4-7" tabindex="-1"></a> parent <span class="ot"><-</span> Text</span> |
| 481 |
<span id="cb4-8"><a href="#cb4-8" tabindex="-1"></a> classes <span class="ot"><-</span> <span class="fu">gen_character</span>(num_classes, <span class="at">min =</span> class_nchar, <span class="at">max =</span> class_nchar)</span> |
| 482 |
<span id="cb4-9"><a href="#cb4-9" tabindex="-1"></a> env <span class="ot"><-</span> <span class="fu">new.env</span>()</span> |
| 483 |
<span id="cb4-10"><a href="#cb4-10" tabindex="-1"></a> <span class="cf">for</span> (x <span class="cf">in</span> classes) {</span> |
| 484 |
<span id="cb4-11"><a href="#cb4-11" tabindex="-1"></a> <span class="fu">assign</span>(x, <span class="fu">new_class</span>(x, <span class="at">parent =</span> parent), env)</span> |
| 485 |
<span id="cb4-12"><a href="#cb4-12" tabindex="-1"></a> parent <span class="ot"><-</span> <span class="fu">get</span>(x, env)</span> |
| 486 |
<span id="cb4-13"><a href="#cb4-13" tabindex="-1"></a> }</span> |
| 487 |
<span id="cb4-14"><a href="#cb4-14" tabindex="-1"></a></span> |
| 488 |
<span id="cb4-15"><a href="#cb4-15" tabindex="-1"></a> <span class="co"># Get the last defined class</span></span> |
| 489 |
<span id="cb4-16"><a href="#cb4-16" tabindex="-1"></a> cls <span class="ot"><-</span> parent</span> |
| 490 |
<span id="cb4-17"><a href="#cb4-17" tabindex="-1"></a></span> |
| 491 |
<span id="cb4-18"><a href="#cb4-18" tabindex="-1"></a> <span class="co"># Construct an object of that class</span></span> |
| 492 |
<span id="cb4-19"><a href="#cb4-19" tabindex="-1"></a> x <span class="ot"><-</span> <span class="fu">do.call</span>(cls, <span class="fu">list</span>(<span class="st">"hi"</span>))</span> |
| 493 |
<span id="cb4-20"><a href="#cb4-20" tabindex="-1"></a> y <span class="ot"><-</span> <span class="fu">do.call</span>(cls, <span class="fu">list</span>(<span class="st">"ho"</span>))</span> |
| 494 |
<span id="cb4-21"><a href="#cb4-21" tabindex="-1"></a></span> |
| 495 |
<span id="cb4-22"><a href="#cb4-22" tabindex="-1"></a> <span class="co"># Define a generic and a method for the last class (best case scenario)</span></span> |
| 496 |
<span id="cb4-23"><a href="#cb4-23" tabindex="-1"></a> foo_S7 <span class="ot"><-</span> <span class="fu">new_generic</span>(<span class="st">"foo_S7"</span>, <span class="fu">c</span>(<span class="st">"x"</span>, <span class="st">"y"</span>))</span> |
| 497 |
<span id="cb4-24"><a href="#cb4-24" tabindex="-1"></a> <span class="fu">method</span>(foo_S7, <span class="fu">list</span>(cls, cls)) <span class="ot"><-</span> <span class="cf">function</span>(x, y, ...) <span class="fu">paste0</span>(x, y, <span class="st">"-foo"</span>)</span> |
| 498 |
<span id="cb4-25"><a href="#cb4-25" tabindex="-1"></a></span> |
| 499 |
<span id="cb4-26"><a href="#cb4-26" tabindex="-1"></a> <span class="co"># Define a generic and a method for the first class (worst case scenario)</span></span> |
| 500 |
<span id="cb4-27"><a href="#cb4-27" tabindex="-1"></a> foo2_S7 <span class="ot"><-</span> <span class="fu">new_generic</span>(<span class="st">"foo2_S7"</span>, <span class="fu">c</span>(<span class="st">"x"</span>, <span class="st">"y"</span>))</span> |
| 501 |
<span id="cb4-28"><a href="#cb4-28" tabindex="-1"></a> <span class="fu">method</span>(foo2_S7, <span class="fu">list</span>(S7_object, S7_object)) <span class="ot"><-</span> <span class="cf">function</span>(x, y, ...) <span class="fu">paste0</span>(x, y, <span class="st">"-foo"</span>)</span> |
| 502 |
<span id="cb4-29"><a href="#cb4-29" tabindex="-1"></a></span> |
| 503 |
<span id="cb4-30"><a href="#cb4-30" tabindex="-1"></a> bench<span class="sc">::</span><span class="fu">mark</span>(</span> |
| 504 |
<span id="cb4-31"><a href="#cb4-31" tabindex="-1"></a> <span class="at">best =</span> <span class="fu">foo_S7</span>(x, y),</span> |
| 505 |
<span id="cb4-32"><a href="#cb4-32" tabindex="-1"></a> <span class="at">worst =</span> <span class="fu">foo2_S7</span>(x, y)</span> |
| 506 |
<span id="cb4-33"><a href="#cb4-33" tabindex="-1"></a> )</span> |
| 507 |
<span id="cb4-34"><a href="#cb4-34" tabindex="-1"></a> }</span> |
| 508 |
<span id="cb4-35"><a href="#cb4-35" tabindex="-1"></a>)</span> |
| 509 |
<span id="cb4-36"><a href="#cb4-36" tabindex="-1"></a><span class="co">#> # A tibble: 20 × 8</span></span> |
| 510 |
<span id="cb4-37"><a href="#cb4-37" tabindex="-1"></a><span class="co">#> expression num_classes class_nchar min median `itr/sec` mem_alloc `gc/sec`</span></span> |
| 511 |
<span id="cb4-38"><a href="#cb4-38" tabindex="-1"></a><span class="co">#> <bch:expr> <dbl> <dbl> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl></span></span> |
| 512 |
<span id="cb4-39"><a href="#cb4-39" tabindex="-1"></a><span class="co">#> 1 best 3 15 3.08µs 3.69µs 263334. 0B 79.0</span></span> |
| 513 |
<span id="cb4-40"><a href="#cb4-40" tabindex="-1"></a><span class="co">#> 2 worst 3 15 3.32µs 3.94µs 249928. 0B 100. </span></span> |
| 514 |
<span id="cb4-41"><a href="#cb4-41" tabindex="-1"></a><span class="co">#> 3 best 5 15 3.08µs 3.77µs 263260. 0B 105. </span></span> |
| 515 |
<span id="cb4-42"><a href="#cb4-42" tabindex="-1"></a><span class="co">#> 4 worst 5 15 3.28µs 3.9µs 256256. 0B 76.9</span></span> |
| 516 |
<span id="cb4-43"><a href="#cb4-43" tabindex="-1"></a><span class="co">#> 5 best 10 15 3.08µs 3.65µs 269725. 0B 108. </span></span> |
| 517 |
<span id="cb4-44"><a href="#cb4-44" tabindex="-1"></a><span class="co">#> 6 worst 10 15 3.48µs 4.1µs 243635. 0B 73.1</span></span> |
| 518 |
<span id="cb4-45"><a href="#cb4-45" tabindex="-1"></a><span class="co">#> 7 best 50 15 3.53µs 4.1µs 246041. 0B 98.5</span></span> |
| 519 |
<span id="cb4-46"><a href="#cb4-46" tabindex="-1"></a><span class="co">#> 8 worst 50 15 5.29µs 6.11µs 165180. 0B 49.6</span></span> |
| 520 |
<span id="cb4-47"><a href="#cb4-47" tabindex="-1"></a><span class="co">#> 9 best 100 15 4.1µs 4.76µs 208298. 0B 62.5</span></span> |
| 521 |
<span id="cb4-48"><a href="#cb4-48" tabindex="-1"></a><span class="co">#> 10 worst 100 15 7.46µs 8.61µs 117170. 0B 46.9</span></span> |
| 522 |
<span id="cb4-49"><a href="#cb4-49" tabindex="-1"></a><span class="co">#> 11 best 3 100 3.08µs 3.65µs 273386. 0B 82.0</span></span> |
| 523 |
<span id="cb4-50"><a href="#cb4-50" tabindex="-1"></a><span class="co">#> 12 worst 3 100 3.65µs 4.26µs 235268. 0B 70.6</span></span> |
| 524 |
<span id="cb4-51"><a href="#cb4-51" tabindex="-1"></a><span class="co">#> 13 best 5 100 3.32µs 3.98µs 251051. 0B 75.3</span></span> |
| 525 |
<span id="cb4-52"><a href="#cb4-52" tabindex="-1"></a><span class="co">#> 14 worst 5 100 4.06µs 4.67µs 214362. 0B 64.3</span></span> |
| 526 |
<span id="cb4-53"><a href="#cb4-53" tabindex="-1"></a><span class="co">#> 15 best 10 100 3.08µs 3.65µs 272562. 0B 109. </span></span> |
| 527 |
<span id="cb4-54"><a href="#cb4-54" tabindex="-1"></a><span class="co">#> 16 worst 10 100 4.43µs 5.08µs 196608. 0B 59.0</span></span> |
| 528 |
<span id="cb4-55"><a href="#cb4-55" tabindex="-1"></a><span class="co">#> 17 best 50 100 3.77µs 4.47µs 223699. 0B 67.1</span></span> |
| 529 |
<span id="cb4-56"><a href="#cb4-56" tabindex="-1"></a><span class="co">#> 18 worst 50 100 10.58µs 11.23µs 85277. 0B 25.6</span></span> |
| 530 |
<span id="cb4-57"><a href="#cb4-57" tabindex="-1"></a><span class="co">#> 19 best 100 100 4.26µs 5µs 197339. 0B 79.0</span></span> |
| 531 |
<span id="cb4-58"><a href="#cb4-58" tabindex="-1"></a><span class="co">#> 20 worst 100 100 17.02µs 17.63µs 55098. 0B 16.5</span></span></code></pre></div> |
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
<script> |
| 540 |
(function () { |
| 541 |
var script = document.createElement("script"); |
| 542 |
script.type = "text/javascript"; |
| 543 |
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; |
| 544 |
document.getElementsByTagName("head")[0].appendChild(script); |
| 545 |
})(); |
| 546 |
</script> |
| 547 |
|
| 548 |
</body> |
| 549 |
</html> |