mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 12:31:58 +02:00
v1.1.0
This commit is contained in:
@ -13,19 +13,20 @@
|
||||
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
|
||||
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
|
||||
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.1/css/all.min.css" integrity="sha256-PbSmjxuVAzJ6FPvNYsrXygfGhNJYyZ2GktDbkMBqQZg=" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.1/css/v4-shims.min.css" integrity="sha256-A6jcAdwFD48VMjlI3GDxUd+eCQa7/KWy6G9oe/ovaPA=" crossorigin="anonymous">
|
||||
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css">
|
||||
<script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
|
||||
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
|
||||
<script src="../extra.js"></script><meta property="og:title" content="Benchmarks">
|
||||
<meta property="og:description" content="AMR">
|
||||
<meta property="og:image" content="/logo.svg">
|
||||
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.svg">
|
||||
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<body data-spy="scroll" data-target="#toc">
|
||||
<div class="container template-article">
|
||||
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
@ -38,7 +39,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -182,12 +183,12 @@
|
||||
</header><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1>Benchmarks</h1>
|
||||
<h1 data-toc-skip>Benchmarks</h1>
|
||||
<h4 class="author">Matthijs S. Berends</h4>
|
||||
|
||||
<h4 class="date">17 March 2020</h4>
|
||||
|
||||
<h4 class="date">15 April 2020</h4>
|
||||
|
||||
<small class="dont-index">Source: <a href="https://gitlab.com/msberends/AMR/blob/master/vignettes/benchmarks.Rmd"><code>vignettes/benchmarks.Rmd</code></a></small>
|
||||
<div class="hidden name"><code>benchmarks.Rmd</code></div>
|
||||
|
||||
</div>
|
||||
@ -196,83 +197,68 @@
|
||||
|
||||
<p>One of the most important features of this package is the complete microbial taxonomic database, supplied by the <a href="http://catalogueoflife.org">Catalogue of Life</a>. We created a function <code><a href="../reference/as.mo.html">as.mo()</a></code> that transforms any user input value to a valid microbial ID by using intelligent rules combined with the taxonomic tree of Catalogue of Life.</p>
|
||||
<p>Using the <code>microbenchmark</code> package, we can review the calculation performance of this function. Its function <code><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark()</a></code> runs different input expressions independently of each other and measures their time-to-result.</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1"></a><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(microbenchmark)</span>
|
||||
<span id="cb1-2"><a href="#cb1-2"></a><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(AMR)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/base/library.html">library</a></span>(<span class="no">microbenchmark</span>)
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/library.html">library</a></span>(<span class="no">AMR</span>)</pre></body></html></div>
|
||||
<p>In the next test, we try to ‘coerce’ different input values into the microbial code of <em>Staphylococcus aureus</em>. Coercion is a computational process of forcing output based on an input. For microorganism names, coercing user input to taxonomically valid microorganism names is crucial to ensure correct interpretation and to enable grouping based on taxonomic properties.</p>
|
||||
<p>The actual result is the same every time: it returns its microorganism code <code>B_STPHY_AURS</code> (<em>B</em> stands for <em>Bacteria</em>, the taxonomic kingdom).</p>
|
||||
<p>But the calculation time differs a lot:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1"></a>S.aureus <-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(</span>
|
||||
<span id="cb2-2"><a href="#cb2-2"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"sau"</span>), <span class="co"># WHONET code</span></span>
|
||||
<span id="cb2-3"><a href="#cb2-3"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"stau"</span>),</span>
|
||||
<span id="cb2-4"><a href="#cb2-4"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"STAU"</span>),</span>
|
||||
<span id="cb2-5"><a href="#cb2-5"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"staaur"</span>),</span>
|
||||
<span id="cb2-6"><a href="#cb2-6"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"STAAUR"</span>),</span>
|
||||
<span id="cb2-7"><a href="#cb2-7"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"S. aureus"</span>),</span>
|
||||
<span id="cb2-8"><a href="#cb2-8"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"S aureus"</span>),</span>
|
||||
<span id="cb2-9"><a href="#cb2-9"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"Staphylococcus aureus"</span>), <span class="co"># official taxonomic name</span></span>
|
||||
<span id="cb2-10"><a href="#cb2-10"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"Staphylococcus aureus (MRSA)"</span>), <span class="co"># additional text</span></span>
|
||||
<span id="cb2-11"><a href="#cb2-11"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"Sthafilokkockus aaureuz"</span>), <span class="co"># incorrect spelling</span></span>
|
||||
<span id="cb2-12"><a href="#cb2-12"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"MRSA"</span>), <span class="co"># Methicillin Resistant S. aureus</span></span>
|
||||
<span id="cb2-13"><a href="#cb2-13"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"VISA"</span>), <span class="co"># Vancomycin Intermediate S. aureus</span></span>
|
||||
<span id="cb2-14"><a href="#cb2-14"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"VRSA"</span>), <span class="co"># Vancomycin Resistant S. aureus</span></span>
|
||||
<span id="cb2-15"><a href="#cb2-15"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="dv">22242419</span>), <span class="co"># Catalogue of Life ID</span></span>
|
||||
<span id="cb2-16"><a href="#cb2-16"></a> <span class="dt">times =</span> <span class="dv">10</span>)</span>
|
||||
<span id="cb2-17"><a href="#cb2-17"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(S.aureus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</span>
|
||||
<span id="cb2-18"><a href="#cb2-18"></a><span class="co"># Unit: milliseconds</span></span>
|
||||
<span id="cb2-19"><a href="#cb2-19"></a><span class="co"># expr min lq mean median uq max</span></span>
|
||||
<span id="cb2-20"><a href="#cb2-20"></a><span class="co"># as.mo("sau") 9.1 9.5 12.0 9.8 10.0 34.0</span></span>
|
||||
<span id="cb2-21"><a href="#cb2-21"></a><span class="co"># as.mo("stau") 38.0 41.0 55.0 41.0 42.0 160.0</span></span>
|
||||
<span id="cb2-22"><a href="#cb2-22"></a><span class="co"># as.mo("STAU") 41.0 41.0 50.0 44.0 63.0 67.0</span></span>
|
||||
<span id="cb2-23"><a href="#cb2-23"></a><span class="co"># as.mo("staaur") 8.6 8.8 9.4 9.4 9.6 10.0</span></span>
|
||||
<span id="cb2-24"><a href="#cb2-24"></a><span class="co"># as.mo("STAAUR") 8.6 8.8 12.0 9.3 9.8 37.0</span></span>
|
||||
<span id="cb2-25"><a href="#cb2-25"></a><span class="co"># as.mo("S. aureus") 14.0 15.0 51.0 27.0 43.0 250.0</span></span>
|
||||
<span id="cb2-26"><a href="#cb2-26"></a><span class="co"># as.mo("S aureus") 14.0 15.0 16.0 15.0 16.0 18.0</span></span>
|
||||
<span id="cb2-27"><a href="#cb2-27"></a><span class="co"># as.mo("Staphylococcus aureus") 5.1 5.3 5.7 5.5 6.0 6.6</span></span>
|
||||
<span id="cb2-28"><a href="#cb2-28"></a><span class="co"># as.mo("Staphylococcus aureus (MRSA)") 640.0 670.0 700.0 690.0 730.0 760.0</span></span>
|
||||
<span id="cb2-29"><a href="#cb2-29"></a><span class="co"># as.mo("Sthafilokkockus aaureuz") 370.0 380.0 420.0 400.0 440.0 510.0</span></span>
|
||||
<span id="cb2-30"><a href="#cb2-30"></a><span class="co"># as.mo("MRSA") 8.6 8.7 11.0 9.1 9.6 32.0</span></span>
|
||||
<span id="cb2-31"><a href="#cb2-31"></a><span class="co"># as.mo("VISA") 24.0 25.0 38.0 38.0 50.0 53.0</span></span>
|
||||
<span id="cb2-32"><a href="#cb2-32"></a><span class="co"># as.mo("VRSA") 24.0 25.0 49.0 37.0 52.0 150.0</span></span>
|
||||
<span id="cb2-33"><a href="#cb2-33"></a><span class="co"># as.mo(22242419) 130.0 140.0 150.0 140.0 160.0 160.0</span></span>
|
||||
<span id="cb2-34"><a href="#cb2-34"></a><span class="co"># neval</span></span>
|
||||
<span id="cb2-35"><a href="#cb2-35"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-36"><a href="#cb2-36"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-37"><a href="#cb2-37"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-38"><a href="#cb2-38"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-39"><a href="#cb2-39"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-40"><a href="#cb2-40"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-41"><a href="#cb2-41"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-42"><a href="#cb2-42"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-43"><a href="#cb2-43"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-44"><a href="#cb2-44"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-45"><a href="#cb2-45"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-46"><a href="#cb2-46"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-47"><a href="#cb2-47"></a><span class="co"># 10</span></span>
|
||||
<span id="cb2-48"><a href="#cb2-48"></a><span class="co"># 10</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><html><body><pre class="r"><span class="no">S.aureus</span> <span class="kw"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"sau"</span>), <span class="co"># WHONET code</span>
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"stau"</span>),
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"STAU"</span>),
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"staaur"</span>),
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"STAAUR"</span>),
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"S. aureus"</span>),
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"S aureus"</span>),
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"Staphylococcus aureus"</span>), <span class="co"># official taxonomic name</span>
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"Staphylococcus aureus (MRSA)"</span>), <span class="co"># additional text</span>
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"Sthafilokkockus aaureuz"</span>), <span class="co"># incorrect spelling</span>
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"MRSA"</span>), <span class="co"># Methicillin Resistant S. aureus</span>
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"VISA"</span>), <span class="co"># Vancomycin Intermediate S. aureus</span>
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"VRSA"</span>), <span class="co"># Vancomycin Resistant S. aureus</span>
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="fl">22242419</span>), <span class="co"># Catalogue of Life ID</span>
|
||||
<span class="kw">times</span> <span class="kw">=</span> <span class="fl">10</span>)
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="no">S.aureus</span>, <span class="kw">unit</span> <span class="kw">=</span> <span class="st">"ms"</span>, <span class="kw">signif</span> <span class="kw">=</span> <span class="fl">2</span>)
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># as.mo("sau") 10.0 11.0 11 11.0 11.0 11 10</span>
|
||||
<span class="co"># as.mo("stau") 39.0 43.0 54 44.0 70.0 72 10</span>
|
||||
<span class="co"># as.mo("STAU") 43.0 44.0 52 47.0 68.0 71 10</span>
|
||||
<span class="co"># as.mo("staaur") 9.6 9.8 11 11.0 12.0 13 10</span>
|
||||
<span class="co"># as.mo("STAAUR") 9.6 11.0 17 11.0 11.0 45 10</span>
|
||||
<span class="co"># as.mo("S. aureus") 15.0 17.0 26 18.0 43.0 50 10</span>
|
||||
<span class="co"># as.mo("S aureus") 16.0 17.0 23 18.0 21.0 44 10</span>
|
||||
<span class="co"># as.mo("Staphylococcus aureus") 6.0 6.0 12 6.9 7.2 40 10</span>
|
||||
<span class="co"># as.mo("Staphylococcus aureus (MRSA)") 660.0 740.0 780 780.0 810.0 870 10</span>
|
||||
<span class="co"># as.mo("Sthafilokkockus aaureuz") 370.0 430.0 470 450.0 460.0 760 10</span>
|
||||
<span class="co"># as.mo("MRSA") 9.5 9.6 13 11.0 11.0 35 10</span>
|
||||
<span class="co"># as.mo("VISA") 25.0 26.0 38 30.0 50.0 58 10</span>
|
||||
<span class="co"># as.mo("VRSA") 25.0 29.0 55 55.0 56.0 150 10</span>
|
||||
<span class="co"># as.mo(22242419) 130.0 150.0 160 160.0 170.0 170 10</span></pre></body></html></div>
|
||||
<p><img src="benchmarks_files/figure-html/unnamed-chunk-4-1.png" width="562.5"></p>
|
||||
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second.</p>
|
||||
<p>To achieve this speed, the <code>as.mo</code> function also takes into account the prevalence of human pathogenic microorganisms. The downside of this is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of <em>Methanosarcina semesiae</em> (<code>B_MTHNSR_SEMS</code>), a bug probably never found before in humans:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1"></a>M.semesiae <-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(<span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"metsem"</span>),</span>
|
||||
<span id="cb3-2"><a href="#cb3-2"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"METSEM"</span>),</span>
|
||||
<span id="cb3-3"><a href="#cb3-3"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"M. semesiae"</span>),</span>
|
||||
<span id="cb3-4"><a href="#cb3-4"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"M. semesiae"</span>),</span>
|
||||
<span id="cb3-5"><a href="#cb3-5"></a> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"Methanosarcina semesiae"</span>),</span>
|
||||
<span id="cb3-6"><a href="#cb3-6"></a> <span class="dt">times =</span> <span class="dv">10</span>)</span>
|
||||
<span id="cb3-7"><a href="#cb3-7"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(M.semesiae, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</span>
|
||||
<span id="cb3-8"><a href="#cb3-8"></a><span class="co"># Unit: milliseconds</span></span>
|
||||
<span id="cb3-9"><a href="#cb3-9"></a><span class="co"># expr min lq mean median uq</span></span>
|
||||
<span id="cb3-10"><a href="#cb3-10"></a><span class="co"># as.mo("metsem") 1530.00 1561.000 1618.00 1620.000 1665.000</span></span>
|
||||
<span id="cb3-11"><a href="#cb3-11"></a><span class="co"># as.mo("METSEM") 1482.00 1523.000 1544.00 1555.000 1567.000</span></span>
|
||||
<span id="cb3-12"><a href="#cb3-12"></a><span class="co"># as.mo("M. semesiae") 15.01 16.140 27.85 17.080 43.620</span></span>
|
||||
<span id="cb3-13"><a href="#cb3-13"></a><span class="co"># as.mo("M. semesiae") 15.54 16.200 19.30 16.570 17.040</span></span>
|
||||
<span id="cb3-14"><a href="#cb3-14"></a><span class="co"># as.mo("Methanosarcina semesiae") 6.05 6.307 9.35 6.437 7.649</span></span>
|
||||
<span id="cb3-15"><a href="#cb3-15"></a><span class="co"># max neval</span></span>
|
||||
<span id="cb3-16"><a href="#cb3-16"></a><span class="co"># 1710.00 10</span></span>
|
||||
<span id="cb3-17"><a href="#cb3-17"></a><span class="co"># 1586.00 10</span></span>
|
||||
<span id="cb3-18"><a href="#cb3-18"></a><span class="co"># 50.39 10</span></span>
|
||||
<span id="cb3-19"><a href="#cb3-19"></a><span class="co"># 42.95 10</span></span>
|
||||
<span id="cb3-20"><a href="#cb3-20"></a><span class="co"># 33.42 10</span></span></code></pre></div>
|
||||
<p>That takes 5.7 times as much time on average. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Methanosarcina semesiae</em>) are always very fast and only take some thousands of seconds to coerce - they are the most probable input from most data sets.</p>
|
||||
<div class="sourceCode" id="cb3"><html><body><pre class="r"><span class="no">M.semesiae</span> <span class="kw"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"metsem"</span>),
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"METSEM"</span>),
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"M. semesiae"</span>),
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"M. semesiae"</span>),
|
||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"Methanosarcina semesiae"</span>),
|
||||
<span class="kw">times</span> <span class="kw">=</span> <span class="fl">10</span>)
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="no">M.semesiae</span>, <span class="kw">unit</span> <span class="kw">=</span> <span class="st">"ms"</span>, <span class="kw">signif</span> <span class="kw">=</span> <span class="fl">4</span>)
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq</span>
|
||||
<span class="co"># as.mo("metsem") 1629.000 1648.000 1694.000 1681.000 1734.000</span>
|
||||
<span class="co"># as.mo("METSEM") 1577.000 1604.000 1675.000 1685.000 1700.000</span>
|
||||
<span class="co"># as.mo("M. semesiae") 17.390 17.470 26.150 18.020 43.560</span>
|
||||
<span class="co"># as.mo("M. semesiae") 17.390 17.880 27.570 18.310 45.910</span>
|
||||
<span class="co"># as.mo("Methanosarcina semesiae") 6.988 7.067 7.443 7.262 7.733</span>
|
||||
<span class="co"># max neval</span>
|
||||
<span class="co"># 1825.000 10</span>
|
||||
<span class="co"># 1793.000 10</span>
|
||||
<span class="co"># 48.390 10</span>
|
||||
<span class="co"># 50.960 10</span>
|
||||
<span class="co"># 8.381 10</span></pre></body></html></div>
|
||||
<p>That takes 5.6 times as much time on average. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Methanosarcina semesiae</em>) are always very fast and only take some thousands of seconds to coerce - they are the most probable input from most data sets.</p>
|
||||
<p>In the figure below, we compare <em>Escherichia coli</em> (which is very common) with <em>Prevotella brevis</em> (which is moderately common) and with <em>Methanosarcina semesiae</em> (which is uncommon):</p>
|
||||
<p><img src="benchmarks_files/figure-html/unnamed-chunk-6-1.png" width="900"></p>
|
||||
<p>Uncommon microorganisms take a lot more time than common microorganisms. To relieve this pitfall and further improve performance, two important calculations take almost no time at all: <strong>repetitive results</strong> and <strong>already precalculated results</strong>.</p>
|
||||
@ -280,103 +266,103 @@
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#repetitive-results" class="anchor"></a>Repetitive results</h3>
|
||||
<p>Repetitive results are unique values that are present more than once. Unique values will only be calculated once by <code><a href="../reference/as.mo.html">as.mo()</a></code>. We will use <code><a href="../reference/mo_property.html">mo_name()</a></code> for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses <code><a href="../reference/as.mo.html">as.mo()</a></code> internally.</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1"></a><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(dplyr)</span>
|
||||
<span id="cb4-2"><a href="#cb4-2"></a><span class="co"># take all MO codes from the example_isolates data set</span></span>
|
||||
<span id="cb4-3"><a href="#cb4-3"></a>x <-<span class="st"> </span>example_isolates<span class="op">$</span>mo <span class="op">%>%</span></span>
|
||||
<span id="cb4-4"><a href="#cb4-4"></a><span class="st"> </span><span class="co"># keep only the unique ones</span></span>
|
||||
<span id="cb4-5"><a href="#cb4-5"></a><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/unique.html">unique</a></span>() <span class="op">%>%</span></span>
|
||||
<span id="cb4-6"><a href="#cb4-6"></a><span class="st"> </span><span class="co"># pick 50 of them at random</span></span>
|
||||
<span id="cb4-7"><a href="#cb4-7"></a><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/sample.html">sample</a></span>(<span class="dv">50</span>) <span class="op">%>%</span></span>
|
||||
<span id="cb4-8"><a href="#cb4-8"></a><span class="st"> </span><span class="co"># paste that 10,000 times</span></span>
|
||||
<span id="cb4-9"><a href="#cb4-9"></a><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/rep.html">rep</a></span>(<span class="dv">10000</span>) <span class="op">%>%</span></span>
|
||||
<span id="cb4-10"><a href="#cb4-10"></a><span class="st"> </span><span class="co"># scramble it</span></span>
|
||||
<span id="cb4-11"><a href="#cb4-11"></a><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/sample.html">sample</a></span>()</span>
|
||||
<span id="cb4-12"><a href="#cb4-12"></a> </span>
|
||||
<span id="cb4-13"><a href="#cb4-13"></a><span class="co"># got indeed 50 times 10,000 = half a million?</span></span>
|
||||
<span id="cb4-14"><a href="#cb4-14"></a><span class="kw"><a href="https://rdrr.io/r/base/length.html">length</a></span>(x)</span>
|
||||
<span id="cb4-15"><a href="#cb4-15"></a><span class="co"># [1] 500000</span></span>
|
||||
<span id="cb4-16"><a href="#cb4-16"></a></span>
|
||||
<span id="cb4-17"><a href="#cb4-17"></a><span class="co"># and how many unique values do we have?</span></span>
|
||||
<span id="cb4-18"><a href="#cb4-18"></a><span class="kw"><a href="https://dplyr.tidyverse.org/reference/n_distinct.html">n_distinct</a></span>(x)</span>
|
||||
<span id="cb4-19"><a href="#cb4-19"></a><span class="co"># [1] 50</span></span>
|
||||
<span id="cb4-20"><a href="#cb4-20"></a></span>
|
||||
<span id="cb4-21"><a href="#cb4-21"></a><span class="co"># now let's see:</span></span>
|
||||
<span id="cb4-22"><a href="#cb4-22"></a>run_it <-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(x),</span>
|
||||
<span id="cb4-23"><a href="#cb4-23"></a> <span class="dt">times =</span> <span class="dv">100</span>)</span>
|
||||
<span id="cb4-24"><a href="#cb4-24"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</span>
|
||||
<span id="cb4-25"><a href="#cb4-25"></a><span class="co"># Unit: milliseconds</span></span>
|
||||
<span id="cb4-26"><a href="#cb4-26"></a><span class="co"># expr min lq mean median uq max neval</span></span>
|
||||
<span id="cb4-27"><a href="#cb4-27"></a><span class="co"># mo_name(x) 572 626 648 645 666 792 100</span></span></code></pre></div>
|
||||
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.64 seconds (644 ms). You only lose time on your unique input values.</p>
|
||||
<div class="sourceCode" id="cb4"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/base/library.html">library</a></span>(<span class="no">dplyr</span>)
|
||||
<span class="co"># take all MO codes from the example_isolates data set</span>
|
||||
<span class="no">x</span> <span class="kw"><-</span> <span class="no">example_isolates</span>$<span class="no">mo</span> <span class="kw">%>%</span>
|
||||
<span class="co"># keep only the unique ones</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span>() <span class="kw">%>%</span>
|
||||
<span class="co"># pick 50 of them at random</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/sample.html">sample</a></span>(<span class="fl">50</span>) <span class="kw">%>%</span>
|
||||
<span class="co"># paste that 10,000 times</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/rep.html">rep</a></span>(<span class="fl">10000</span>) <span class="kw">%>%</span>
|
||||
<span class="co"># scramble it</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/sample.html">sample</a></span>()
|
||||
|
||||
<span class="co"># got indeed 50 times 10,000 = half a million?</span>
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/length.html">length</a></span>(<span class="no">x</span>)
|
||||
<span class="co"># [1] 500000</span>
|
||||
|
||||
<span class="co"># and how many unique values do we have?</span>
|
||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/n_distinct.html">n_distinct</a></span>(<span class="no">x</span>)
|
||||
<span class="co"># [1] 50</span>
|
||||
|
||||
<span class="co"># now let's see:</span>
|
||||
<span class="no">run_it</span> <span class="kw"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(<span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="no">x</span>),
|
||||
<span class="kw">times</span> <span class="kw">=</span> <span class="fl">100</span>)
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="no">run_it</span>, <span class="kw">unit</span> <span class="kw">=</span> <span class="st">"ms"</span>, <span class="kw">signif</span> <span class="kw">=</span> <span class="fl">3</span>)
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># mo_name(x) 1730 1790 1830 1810 1860 2030 100</span></pre></body></html></div>
|
||||
<p>So transforming 500,000 values (!!) of 50 unique values only takes 1.81 seconds (1814 ms). You only lose time on your unique input values.</p>
|
||||
</div>
|
||||
<div id="precalculated-results" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#precalculated-results" class="anchor"></a>Precalculated results</h3>
|
||||
<p>What about precalculated results? If the input is an already precalculated result of a helper function like <code><a href="../reference/mo_property.html">mo_name()</a></code>, it almost doesn’t take any time at all (see ‘C’ below):</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1"></a>run_it <-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"B_STPHY_AURS"</span>),</span>
|
||||
<span id="cb5-2"><a href="#cb5-2"></a> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"S. aureus"</span>),</span>
|
||||
<span id="cb5-3"><a href="#cb5-3"></a> <span class="dt">C =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"Staphylococcus aureus"</span>),</span>
|
||||
<span id="cb5-4"><a href="#cb5-4"></a> <span class="dt">times =</span> <span class="dv">10</span>)</span>
|
||||
<span id="cb5-5"><a href="#cb5-5"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</span>
|
||||
<span id="cb5-6"><a href="#cb5-6"></a><span class="co"># Unit: milliseconds</span></span>
|
||||
<span id="cb5-7"><a href="#cb5-7"></a><span class="co"># expr min lq mean median uq max neval</span></span>
|
||||
<span id="cb5-8"><a href="#cb5-8"></a><span class="co"># A 6.730 6.860 7.110 6.950 7.170 8.47 10</span></span>
|
||||
<span id="cb5-9"><a href="#cb5-9"></a><span class="co"># B 14.500 14.800 18.100 15.500 15.900 43.10 10</span></span>
|
||||
<span id="cb5-10"><a href="#cb5-10"></a><span class="co"># C 0.726 0.753 0.821 0.791 0.882 1.04 10</span></span></code></pre></div>
|
||||
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0008 seconds - it doesn’t even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1"></a>run_it <-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),</span>
|
||||
<span id="cb6-2"><a href="#cb6-2"></a> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),</span>
|
||||
<span id="cb6-3"><a href="#cb6-3"></a> <span class="dt">C =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"Staphylococcus aureus"</span>),</span>
|
||||
<span id="cb6-4"><a href="#cb6-4"></a> <span class="dt">D =</span> <span class="kw"><a href="../reference/mo_property.html">mo_family</a></span>(<span class="st">"Staphylococcaceae"</span>),</span>
|
||||
<span id="cb6-5"><a href="#cb6-5"></a> <span class="dt">E =</span> <span class="kw"><a href="../reference/mo_property.html">mo_order</a></span>(<span class="st">"Bacillales"</span>),</span>
|
||||
<span id="cb6-6"><a href="#cb6-6"></a> <span class="dt">F =</span> <span class="kw"><a href="../reference/mo_property.html">mo_class</a></span>(<span class="st">"Bacilli"</span>),</span>
|
||||
<span id="cb6-7"><a href="#cb6-7"></a> <span class="dt">G =</span> <span class="kw"><a href="../reference/mo_property.html">mo_phylum</a></span>(<span class="st">"Firmicutes"</span>),</span>
|
||||
<span id="cb6-8"><a href="#cb6-8"></a> <span class="dt">H =</span> <span class="kw"><a href="../reference/mo_property.html">mo_kingdom</a></span>(<span class="st">"Bacteria"</span>),</span>
|
||||
<span id="cb6-9"><a href="#cb6-9"></a> <span class="dt">times =</span> <span class="dv">10</span>)</span>
|
||||
<span id="cb6-10"><a href="#cb6-10"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</span>
|
||||
<span id="cb6-11"><a href="#cb6-11"></a><span class="co"># Unit: milliseconds</span></span>
|
||||
<span id="cb6-12"><a href="#cb6-12"></a><span class="co"># expr min lq mean median uq max neval</span></span>
|
||||
<span id="cb6-13"><a href="#cb6-13"></a><span class="co"># A 0.348 0.398 0.405 0.404 0.419 0.438 10</span></span>
|
||||
<span id="cb6-14"><a href="#cb6-14"></a><span class="co"># B 0.407 0.416 0.461 0.426 0.490 0.667 10</span></span>
|
||||
<span id="cb6-15"><a href="#cb6-15"></a><span class="co"># C 0.701 0.745 0.757 0.754 0.769 0.814 10</span></span>
|
||||
<span id="cb6-16"><a href="#cb6-16"></a><span class="co"># D 0.435 0.440 0.497 0.464 0.569 0.588 10</span></span>
|
||||
<span id="cb6-17"><a href="#cb6-17"></a><span class="co"># E 0.351 0.397 0.435 0.419 0.489 0.520 10</span></span>
|
||||
<span id="cb6-18"><a href="#cb6-18"></a><span class="co"># F 0.358 0.385 0.396 0.393 0.420 0.430 10</span></span>
|
||||
<span id="cb6-19"><a href="#cb6-19"></a><span class="co"># G 0.322 0.363 0.409 0.401 0.450 0.508 10</span></span>
|
||||
<span id="cb6-20"><a href="#cb6-20"></a><span class="co"># H 0.340 0.372 0.384 0.385 0.403 0.432 10</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><html><body><pre class="r"><span class="no">run_it</span> <span class="kw"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(<span class="kw">A</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"B_STPHY_AURS"</span>),
|
||||
<span class="kw">B</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"S. aureus"</span>),
|
||||
<span class="kw">C</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"Staphylococcus aureus"</span>),
|
||||
<span class="kw">times</span> <span class="kw">=</span> <span class="fl">10</span>)
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="no">run_it</span>, <span class="kw">unit</span> <span class="kw">=</span> <span class="st">"ms"</span>, <span class="kw">signif</span> <span class="kw">=</span> <span class="fl">3</span>)
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># A 7.26 7.390 8.020 7.450 7.500 11.100 10</span>
|
||||
<span class="co"># B 15.30 15.700 20.500 15.800 17.000 56.300 10</span>
|
||||
<span class="co"># C 0.58 0.718 0.735 0.726 0.747 0.927 10</span></pre></body></html></div>
|
||||
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0007 seconds - it doesn’t even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
|
||||
<div class="sourceCode" id="cb6"><html><body><pre class="r"><span class="no">run_it</span> <span class="kw"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(<span class="kw">A</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),
|
||||
<span class="kw">B</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),
|
||||
<span class="kw">C</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"Staphylococcus aureus"</span>),
|
||||
<span class="kw">D</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_family</a></span>(<span class="st">"Staphylococcaceae"</span>),
|
||||
<span class="kw">E</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_order</a></span>(<span class="st">"Bacillales"</span>),
|
||||
<span class="kw">F</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_class</a></span>(<span class="st">"Bacilli"</span>),
|
||||
<span class="kw">G</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_phylum</a></span>(<span class="st">"Firmicutes"</span>),
|
||||
<span class="kw">H</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_kingdom</a></span>(<span class="st">"Bacteria"</span>),
|
||||
<span class="kw">times</span> <span class="kw">=</span> <span class="fl">10</span>)
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="no">run_it</span>, <span class="kw">unit</span> <span class="kw">=</span> <span class="st">"ms"</span>, <span class="kw">signif</span> <span class="kw">=</span> <span class="fl">3</span>)
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># A 0.380 0.386 0.397 0.394 0.397 0.434 10</span>
|
||||
<span class="co"># B 0.413 0.417 0.444 0.424 0.430 0.627 10</span>
|
||||
<span class="co"># C 0.574 0.680 0.707 0.730 0.735 0.776 10</span>
|
||||
<span class="co"># D 0.407 0.419 0.430 0.430 0.435 0.470 10</span>
|
||||
<span class="co"># E 0.374 0.381 0.401 0.397 0.424 0.438 10</span>
|
||||
<span class="co"># F 0.366 0.380 0.389 0.387 0.395 0.422 10</span>
|
||||
<span class="co"># G 0.367 0.377 0.388 0.383 0.392 0.420 10</span>
|
||||
<span class="co"># H 0.368 0.374 0.386 0.382 0.390 0.430 10</span></pre></body></html></div>
|
||||
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> anyway, there is no point in calculating the result. And because this package ‘knows’ all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.</p>
|
||||
</div>
|
||||
<div id="results-in-other-languages" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#results-in-other-languages" class="anchor"></a>Results in other languages</h3>
|
||||
<p>When the system language is non-English and supported by this <code>AMR</code> package, some functions will have a translated result. This almost does’t take extra time:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1"></a><span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="dt">language =</span> <span class="st">"en"</span>) <span class="co"># or just mo_name("CoNS") on an English system</span></span>
|
||||
<span id="cb7-2"><a href="#cb7-2"></a><span class="co"># [1] "Coagulase-negative Staphylococcus (CoNS)"</span></span>
|
||||
<span id="cb7-3"><a href="#cb7-3"></a></span>
|
||||
<span id="cb7-4"><a href="#cb7-4"></a><span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="dt">language =</span> <span class="st">"es"</span>) <span class="co"># or just mo_name("CoNS") on a Spanish system</span></span>
|
||||
<span id="cb7-5"><a href="#cb7-5"></a><span class="co"># [1] "Staphylococcus coagulasa negativo (SCN)"</span></span>
|
||||
<span id="cb7-6"><a href="#cb7-6"></a></span>
|
||||
<span id="cb7-7"><a href="#cb7-7"></a><span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="dt">language =</span> <span class="st">"nl"</span>) <span class="co"># or just mo_name("CoNS") on a Dutch system</span></span>
|
||||
<span id="cb7-8"><a href="#cb7-8"></a><span class="co"># [1] "Coagulase-negatieve Staphylococcus (CNS)"</span></span>
|
||||
<span id="cb7-9"><a href="#cb7-9"></a></span>
|
||||
<span id="cb7-10"><a href="#cb7-10"></a>run_it <-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(<span class="dt">en =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="dt">language =</span> <span class="st">"en"</span>),</span>
|
||||
<span id="cb7-11"><a href="#cb7-11"></a> <span class="dt">de =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="dt">language =</span> <span class="st">"de"</span>),</span>
|
||||
<span id="cb7-12"><a href="#cb7-12"></a> <span class="dt">nl =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="dt">language =</span> <span class="st">"nl"</span>),</span>
|
||||
<span id="cb7-13"><a href="#cb7-13"></a> <span class="dt">es =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="dt">language =</span> <span class="st">"es"</span>),</span>
|
||||
<span id="cb7-14"><a href="#cb7-14"></a> <span class="dt">it =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="dt">language =</span> <span class="st">"it"</span>),</span>
|
||||
<span id="cb7-15"><a href="#cb7-15"></a> <span class="dt">fr =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="dt">language =</span> <span class="st">"fr"</span>),</span>
|
||||
<span id="cb7-16"><a href="#cb7-16"></a> <span class="dt">pt =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="dt">language =</span> <span class="st">"pt"</span>),</span>
|
||||
<span id="cb7-17"><a href="#cb7-17"></a> <span class="dt">times =</span> <span class="dv">100</span>)</span>
|
||||
<span id="cb7-18"><a href="#cb7-18"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</span>
|
||||
<span id="cb7-19"><a href="#cb7-19"></a><span class="co"># Unit: milliseconds</span></span>
|
||||
<span id="cb7-20"><a href="#cb7-20"></a><span class="co"># expr min lq mean median uq max neval</span></span>
|
||||
<span id="cb7-21"><a href="#cb7-21"></a><span class="co"># en 25.28 26.99 33.53 27.88 29.51 61.96 100</span></span>
|
||||
<span id="cb7-22"><a href="#cb7-22"></a><span class="co"># de 26.99 29.27 36.92 30.02 33.09 160.30 100</span></span>
|
||||
<span id="cb7-23"><a href="#cb7-23"></a><span class="co"># nl 32.37 34.58 40.59 35.88 37.10 67.43 100</span></span>
|
||||
<span id="cb7-24"><a href="#cb7-24"></a><span class="co"># es 27.54 29.14 34.40 29.88 31.45 61.89 100</span></span>
|
||||
<span id="cb7-25"><a href="#cb7-25"></a><span class="co"># it 26.77 28.79 34.28 29.73 31.30 69.41 100</span></span>
|
||||
<span id="cb7-26"><a href="#cb7-26"></a><span class="co"># fr 27.01 28.81 34.96 29.39 30.79 161.10 100</span></span>
|
||||
<span id="cb7-27"><a href="#cb7-27"></a><span class="co"># pt 26.76 28.85 34.13 29.69 31.74 63.08 100</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><html><body><pre class="r"><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"en"</span>) <span class="co"># or just mo_name("CoNS") on an English system</span>
|
||||
<span class="co"># [1] "Coagulase-negative Staphylococcus (CoNS)"</span>
|
||||
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"es"</span>) <span class="co"># or just mo_name("CoNS") on a Spanish system</span>
|
||||
<span class="co"># [1] "Staphylococcus coagulasa negativo (SCN)"</span>
|
||||
|
||||
<span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"nl"</span>) <span class="co"># or just mo_name("CoNS") on a Dutch system</span>
|
||||
<span class="co"># [1] "Coagulase-negatieve Staphylococcus (CNS)"</span>
|
||||
|
||||
<span class="no">run_it</span> <span class="kw"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(<span class="kw">en</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"en"</span>),
|
||||
<span class="kw">de</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"de"</span>),
|
||||
<span class="kw">nl</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"nl"</span>),
|
||||
<span class="kw">es</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"es"</span>),
|
||||
<span class="kw">it</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"it"</span>),
|
||||
<span class="kw">fr</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"fr"</span>),
|
||||
<span class="kw">pt</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"CoNS"</span>, <span class="kw">language</span> <span class="kw">=</span> <span class="st">"pt"</span>),
|
||||
<span class="kw">times</span> <span class="kw">=</span> <span class="fl">100</span>)
|
||||
<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span>(<span class="no">run_it</span>, <span class="kw">unit</span> <span class="kw">=</span> <span class="st">"ms"</span>, <span class="kw">signif</span> <span class="kw">=</span> <span class="fl">4</span>)
|
||||
<span class="co"># Unit: milliseconds</span>
|
||||
<span class="co"># expr min lq mean median uq max neval</span>
|
||||
<span class="co"># en 26.72 28.52 32.86 29.31 30.18 69.18 100</span>
|
||||
<span class="co"># de 27.86 30.67 40.23 31.44 46.42 170.40 100</span>
|
||||
<span class="co"># nl 34.45 36.94 44.89 37.95 40.54 76.41 100</span>
|
||||
<span class="co"># es 27.89 30.51 38.46 31.33 32.89 170.10 100</span>
|
||||
<span class="co"># it 29.15 30.37 35.85 31.04 32.39 65.33 100</span>
|
||||
<span class="co"># fr 28.18 30.37 35.80 31.11 32.25 78.14 100</span>
|
||||
<span class="co"># pt 28.23 30.55 36.89 31.32 32.77 67.79 100</span></pre></body></html></div>
|
||||
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -394,7 +380,7 @@
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.4.1.9000.</p>
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.0.</p>
|
||||
</div>
|
||||
|
||||
</footer>
|
||||
|
Reference in New Issue
Block a user