{"id":20773,"date":"2023-04-28T09:00:00","date_gmt":"2023-04-28T07:00:00","guid":{"rendered":"https:\/\/www.codemotion.com\/magazine\/?p=20773"},"modified":"2023-04-27T10:55:47","modified_gmt":"2023-04-27T08:55:47","slug":"bun-runtime-speed-tests-and-key-features","status":"publish","type":"post","link":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/","title":{"rendered":"Bun Runtime: Speed Tests and Key Features"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"h-introduction\">Introduction<\/h2>\n\n\n\n<p>Let&#8217;s take a look at some key concepts to fully understand Bun runtime: the setting in which JavaScript code executes is referred to as the <strong>JavaScript runtime<\/strong>. It provides the event loop, memory allocation, and garbage collection architecture required to run JavaScript code.<\/p>\n\n\n\n<p>Using a runtime environment like Node.js, JavaScript code can be run in a browser or on a server. <strong>We&#8217;ll examine some intriguing facts about Bun in this article<\/strong>, assess how it stacks up against competing JavaScript runtimes, and examine how to use Bun to launch a React project. <\/p>\n\n\n\n<p>Finally, we&#8217;ll perform some performance tests <strong>to verify that Bun is as quick as it claims<\/strong> to be on its website.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-is-bun-runtime\">What is Bun runtime<\/h2>\n\n\n\n<p>Bun is a runtime for modern applications that are <strong>designed to be faster and more efficient<\/strong> than traditional runtimes. A native bundler, transpiler, task runner, and npm client are all included in the brand-new, lightweight JavaScript runtime known as Bun. <strong>It enables the bundling, installation, and execution of TypeScript and JavaScript projects<\/strong>. Bun is designed to be an all-in-one alternative for Node, Webpack, Babel, and Yarn.<\/p>\n\n\n\n<p>It asserts to be quicker and more feature-rich than <a href=\"https:\/\/www.codemotion.com\/magazine\/languages\/will-bun-replace-deno-as-node-js-killer\/\" target=\"_blank\" aria-label=\"Node.js and Deno (opens in a new tab)\" rel=\"noreferrer noopener\" class=\"ek-link\">Node.js and Deno<\/a>. Bun was designed by Jarred Sumner and made available to the general public in 2021. Since then, it has quickly racked up more than 30k GitHub stars.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-features-of-bun\">Features of Bun<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Transpiling<\/strong><\/h3>\n\n\n\n<p>The excellent transpiler in Bun translates TypeScript, JSX, and even plain JavaScript. Why, therefore, would you want to translate simple JavaScript?<\/p>\n\n\n\n<p>What a wonderful question. <strong>Here, one of Bun&#8217;s performance-improving features is put to use<\/strong>. Before it is executed, Bun automatically optimizes JavaScript.<\/p>\n\n\n\n<p>Although the transpile capability is still in development, the creators want to eventually add an efficient binary format for JavaScript. Edge applications and other transient processes may be significantly impacted by these changes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Task running<\/strong><\/h3>\n\n\n\n<p>Bun&#8217;s task runner is comparable to Node.js, however, it moves much more quickly. To benefit from its speed, you can use Bun&#8217;s task manager in a Node project. A necessary tool is a task runner, which both Node\/npm and Deno come with by default. Additionally, whereas npm can only do this for a select few script names, Bun&#8217;s task manager can launch nearly any script without the requirement for the run subcommand.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Kubernetes integration<\/strong><\/h3>\n\n\n\n<p>Bun is designed to be easy to deploy and manage, with support for containerization and orchestration using Kubernetes. This makes it a good choice for building modern, cloud-native applications that need to be scalable, resilient, and easy to manage.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Using Node.js with Bun without modification<\/strong><\/h3>\n\n\n\n<p>Bun is designed to be compatible with the Node.js API, which means that many native Node modules can be used with Bun without modification. Bun uses a custom implementation of the V8 JavaScript engine, which provides a high degree of compatibility with the Node.js runtime. This allows developers to leverage existing Node.js modules and libraries in their applications, without having to rewrite them or find alternative solutions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>SQLite client<\/strong><\/h3>\n\n\n\n<p>For interacting with SQLite databases, Bun comes with a quick and effective built-in SQLite3 client. The client is perfect for contexts with limited resources because it is speed-optimized and has a small memory footprint. It also includes an easy-to-use, straightforward API.<\/p>\n\n\n\n<figure class=\"wp-block-embed alignfull is-type-wp-embed is-provider-codemotion-magazine wp-block-embed-codemotion-magazine\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"KAMgWg2F5o\"><a href=\"https:\/\/www.codemotion.com\/magazine\/languages\/will-bun-replace-deno-as-node-js-killer\/\">Will Bun replace Deno as Node.JS killer?<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Will Bun replace Deno as Node.JS killer?&#8221; &#8212; Codemotion Magazine\" src=\"https:\/\/www.codemotion.com\/magazine\/languages\/will-bun-replace-deno-as-node-js-killer\/embed\/#?secret=P4kEwW6xSG#?secret=KAMgWg2F5o\" data-secret=\"KAMgWg2F5o\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-why-is-bun-faster\">Why is Bun faster<\/h2>\n\n\n\n<p>Lightweight: Bun is a <strong>lightweight runtime<\/strong>, which means it has a smaller codebase and needs fewer resources, making it perform better than other Runtimes in terms of speed and memory utilization.<\/p>\n\n\n\n<p>Compactness: Bun contains a native transpiler that allows you to write Typescript code right out of the box and a native bundler to take the place of tools like Webpack. Like Jest, Bun features a test runner. You don&#8217;t need to install dozens into each project; environment variables load automatically.<\/p>\n\n\n\n<p>Low-level code: Zig, a low-level programming language that is more recent than C or Rust, is used to create the Bun runtime.<\/p>\n\n\n\n<p>Performance: The v8 engine is not used by Bun. Instead, it makes use of Webkit&#8217;s Javascript core, which is typically thought to be quicker.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-installation-and-setup-of-bun-runtime\">Installation and setup of Bun runtime<\/h2>\n\n\n\n<p>You can visit the <a target=\"_blank\" href=\"https:\/\/bun.sh\/\" rel=\"noreferrer noopener\">website<\/a> and see the official document on how to install Bun, although below is the command:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">curl -fsSL https:<span class=\"hljs-comment\">\/\/bun.sh\/install | bash<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This is supported on macOS, Linux, and Windows.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-bun-as-a-package-manager\">Bun, as a package manager<\/h3>\n\n\n\n<p>In fact, according to Bun\u2019s official <a href=\"https:\/\/github.com\/oven-sh\/bun\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub<\/a> page, Bun can install packages 20 times to 100 times faster than npm install, and on macOS, you can record up to 4 times to 80 times faster than npm install.&nbsp;<\/p>\n\n\n\n<p>You need Bun installed on your system and a project set up to use Bun install. The Bun install command has the following syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">code<\/span>&gt;<\/span>bun install<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">code<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To add packages, use the following:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">code<\/span>&gt;<\/span>bun add <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">package_name<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">code<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To remove packages, use the following:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">code<\/span>&gt;<\/span>bun remove <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">package_name<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">code<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-combining-bun-and-react\">Combining Bun and React<\/h3>\n\n\n\n<p>Let\u2019s set up React application with Bun.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">code<\/span>&gt;<\/span>bun --version<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">code<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The command above verifies that you have Bun runtime installed, your current version of Bun will be displayed on your terminal. Visit their website to see the official documentation for the installation guides on your system.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">code<\/span>&gt;<\/span>bun create<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">code<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The command above previews tools to create.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/paper-attachments.dropboxusercontent.com\/s_1C35712D72BA19224FCE0D4F564EB60EACA6ABD273A62655DB4F46F151DC6DEB_1681336751024_bun+2.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>From the list above, you can see React command, now let\u2019s run it:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">code<\/span>&gt;<\/span>bun create react &#91;app-name]<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">code<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>&nbsp;Now run a development build so your application can start running by using this command:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">code<\/span>&gt;<\/span>\u00a0bun dev<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">code<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-bun-runtime-speed-test\">Bun runtime speed test<\/h3>\n\n\n\n<p>To determine which of these runtimes executes the code the quickest, let&#8217;s conduct a quick speed test. Our software consists of a single loop that we start at program startup and stop when the loop completes its iteration.<\/p>\n\n\n\n<p>Below is our code block for the program:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-built_in\">console<\/span>.time(<span class=\"hljs-string\">'test'<\/span>);\n\n<span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">let<\/span> i = <span class=\"hljs-number\">0<\/span>; i &lt; <span class=\"hljs-number\">10000<\/span>; i++) <span class=\"hljs-built_in\">console<\/span>.log(i)\n\n<span class=\"hljs-built_in\">console<\/span>.timeEnd(<span class=\"hljs-string\">\"test\"<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li>Make a file and give it any name you like; for example, bun-runtime.js.<\/li>\n\n\n\n<li>In the file, paste the code above in the file.<\/li>\n\n\n\n<li>Navigate to your terminal, then go to the folder containing the file.<\/li>\n\n\n\n<li>Run the program below:<\/li>\n<\/ul>\n\n\n\n<p><code>bun [file name]<\/code><\/p>\n\n\n\n<p>See the outcomes below:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/paper-attachments.dropboxusercontent.com\/s_1C35712D72BA19224FCE0D4F564EB60EACA6ABD273A62655DB4F46F151DC6DEB_1681339228146_Screenshot+from+2023-04-12+23-39-36.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Bun completed its loop at 22.39ms&nbsp;<\/p>\n\n\n\n<p>For Node.js run the command below:<\/p>\n\n\n\n<p><code>node [file name]<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/paper-attachments.dropboxusercontent.com\/s_1C35712D72BA19224FCE0D4F564EB60EACA6ABD273A62655DB4F46F151DC6DEB_1681338159191_Screenshot+from+2023-04-12+23-22-05.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Node completed its loop at 163.225ms&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-bun-speed-test-with-react\">Bun speed test with react<\/h3>\n\n\n\n<p>Now that we have installed our Bun and its unique features, let\u2019s test the speed of creating a React project using Bun and using create-react-app.<\/p>\n\n\n\n<p>Go to your terminal and run the command below:<\/p>\n\n\n\n<p><code>bun create react [your-app-name]<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/paper-attachments.dropboxusercontent.com\/s_1C35712D72BA19224FCE0D4F564EB60EACA6ABD273A62655DB4F46F151DC6DEB_1681341743265_PicsArt_04-13-12.14.28.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Creating the React app using Bun didn\u2019t take up to 10 seconds.<\/p>\n\n\n\n<p>For our create-react-app open the terminal and run the command below:<\/p>\n\n\n\n<p><code>npx create-react-app [app-name]<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/paper-attachments.dropboxusercontent.com\/s_1C35712D72BA19224FCE0D4F564EB60EACA6ABD273A62655DB4F46F151DC6DEB_1681341760084_PicsArt_04-13-12.10.45.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>It took React app over 60 seconds to finish installing all dependencies for a new React application.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p>In this article, we knew about Bun runtime, its installation method, features, and how to use it, Bun is a versatile and powerful tool that benefits web developers looking to build fast, efficient and scalable applications. You can also visit the <a target=\"_blank\" href=\"https:\/\/github.com\/oven-sh\/bun\/tree\/e55d6eed2bf9a5db30250fdd8b9be063dc949054\/bench\" rel=\"noreferrer noopener\">GitHub<\/a> page containing lots of benchmark tests you can take out on Bun.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Here are more posts about web and app performance for you:<br><a aria-label=\"Why is Web Performance More Important Than Ever? (opens in a new tab)\" href=\"https:\/\/www.codemotion.com\/magazine\/frontend\/web-developer\/why-is-web-performance-more-important-than-ever\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"ek-link\">Why is Web Performance More Important Than Ever?<\/a><br><a href=\"https:\/\/www.codemotion.com\/magazine\/backend\/how-to-boost-performance-with-lazy-loading\/\" target=\"_blank\" aria-label=\"Boosting Performance with Lazy Loading (opens in a new tab)\" rel=\"noreferrer noopener\" class=\"ek-link\">Boosting Performance with Lazy Loading<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Let&#8217;s take a look at some key concepts to fully understand Bun runtime: the setting in which JavaScript code executes is referred to as the JavaScript runtime. It provides the event loop, memory allocation, and garbage collection architecture required to run JavaScript code. Using a runtime environment like Node.js, JavaScript code can be run&#8230; <a class=\"more-link\" href=\"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/\">Read more<\/a><\/p>\n","protected":false},"author":163,"featured_media":20779,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","_uag_custom_page_level_css":"","_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[6],"tags":[9961,9971],"collections":[],"class_list":{"0":"post-20773","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-frontend","8":"tag-javascript","9":"tag-typescript","10":"entry"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Bun Runtime: Speed Tests and Key Concepts<\/title>\n<meta name=\"description\" content=\"Is Bun runtime as fast as it claims to be? Discover it in this article with a real life test and some more key concepts about Bun.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bun Runtime: Speed Tests and Key Features\" \/>\n<meta property=\"og:description\" content=\"Is Bun runtime as fast as it claims to be? Discover it in this article with a real life test and some more key concepts about Bun.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/\" \/>\n<meta property=\"og:site_name\" content=\"Codemotion Magazine\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Codemotion.Italy\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-28T07:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post-.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1600\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Chukwudi Golden\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CodemotionIT\" \/>\n<meta name=\"twitter:site\" content=\"@CodemotionIT\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Chukwudi Golden\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/bun-runtime-speed-tests-and-key-features\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/bun-runtime-speed-tests-and-key-features\\\/\"},\"author\":{\"name\":\"Chukwudi Golden\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#\\\/schema\\\/person\\\/0ee64d200a6d244e92d780fa0258094e\"},\"headline\":\"Bun Runtime: Speed Tests and Key Features\",\"datePublished\":\"2023-04-28T07:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/bun-runtime-speed-tests-and-key-features\\\/\"},\"wordCount\":1155,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/bun-runtime-speed-tests-and-key-features\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/Minimal-colorful-quote-twitter-post-.jpg\",\"keywords\":[\"JavaScript\",\"typescript\"],\"articleSection\":[\"Frontend\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/bun-runtime-speed-tests-and-key-features\\\/\",\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/bun-runtime-speed-tests-and-key-features\\\/\",\"name\":\"Bun Runtime: Speed Tests and Key Concepts\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/bun-runtime-speed-tests-and-key-features\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/bun-runtime-speed-tests-and-key-features\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/Minimal-colorful-quote-twitter-post-.jpg\",\"datePublished\":\"2023-04-28T07:00:00+00:00\",\"description\":\"Is Bun runtime as fast as it claims to be? Discover it in this article with a real life test and some more key concepts about Bun.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/bun-runtime-speed-tests-and-key-features\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/bun-runtime-speed-tests-and-key-features\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/bun-runtime-speed-tests-and-key-features\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/Minimal-colorful-quote-twitter-post-.jpg\",\"contentUrl\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/Minimal-colorful-quote-twitter-post-.jpg\",\"width\":1600,\"height\":900,\"caption\":\"bun runtime, speed test\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/bun-runtime-speed-tests-and-key-features\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Frontend\",\"item\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Bun Runtime: Speed Tests and Key Features\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#website\",\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/\",\"name\":\"Codemotion Magazine\",\"description\":\"We code the future. Together\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#organization\",\"name\":\"Codemotion\",\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2019\\\/11\\\/codemotionlogo.png\",\"contentUrl\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2019\\\/11\\\/codemotionlogo.png\",\"width\":225,\"height\":225,\"caption\":\"Codemotion\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Codemotion.Italy\\\/\",\"https:\\\/\\\/x.com\\\/CodemotionIT\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#\\\/schema\\\/person\\\/0ee64d200a6d244e92d780fa0258094e\",\"name\":\"Chukwudi Golden\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/df8800832dada5055a69da0d903cd2a2d3f8e777c4cc9bbbd44d4952befae3fc?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/df8800832dada5055a69da0d903cd2a2d3f8e777c4cc9bbbd44d4952befae3fc?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/df8800832dada5055a69da0d903cd2a2d3f8e777c4cc9bbbd44d4952befae3fc?s=96&d=mm&r=g\",\"caption\":\"Chukwudi Golden\"},\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/author\\\/chukwudi-golden\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Bun Runtime: Speed Tests and Key Concepts","description":"Is Bun runtime as fast as it claims to be? Discover it in this article with a real life test and some more key concepts about Bun.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/","og_locale":"en_US","og_type":"article","og_title":"Bun Runtime: Speed Tests and Key Features","og_description":"Is Bun runtime as fast as it claims to be? Discover it in this article with a real life test and some more key concepts about Bun.","og_url":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/","og_site_name":"Codemotion Magazine","article_publisher":"https:\/\/www.facebook.com\/Codemotion.Italy\/","article_published_time":"2023-04-28T07:00:00+00:00","og_image":[{"width":1600,"height":900,"url":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post-.jpg","type":"image\/jpeg"}],"author":"Chukwudi Golden","twitter_card":"summary_large_image","twitter_creator":"@CodemotionIT","twitter_site":"@CodemotionIT","twitter_misc":{"Written by":"Chukwudi Golden","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/#article","isPartOf":{"@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/"},"author":{"name":"Chukwudi Golden","@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/person\/0ee64d200a6d244e92d780fa0258094e"},"headline":"Bun Runtime: Speed Tests and Key Features","datePublished":"2023-04-28T07:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/"},"wordCount":1155,"publisher":{"@id":"https:\/\/www.codemotion.com\/magazine\/#organization"},"image":{"@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post-.jpg","keywords":["JavaScript","typescript"],"articleSection":["Frontend"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/","url":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/","name":"Bun Runtime: Speed Tests and Key Concepts","isPartOf":{"@id":"https:\/\/www.codemotion.com\/magazine\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/#primaryimage"},"image":{"@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post-.jpg","datePublished":"2023-04-28T07:00:00+00:00","description":"Is Bun runtime as fast as it claims to be? Discover it in this article with a real life test and some more key concepts about Bun.","breadcrumb":{"@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/#primaryimage","url":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post-.jpg","contentUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post-.jpg","width":1600,"height":900,"caption":"bun runtime, speed test"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/bun-runtime-speed-tests-and-key-features\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codemotion.com\/magazine\/"},{"@type":"ListItem","position":2,"name":"Frontend","item":"https:\/\/www.codemotion.com\/magazine\/frontend\/"},{"@type":"ListItem","position":3,"name":"Bun Runtime: Speed Tests and Key Features"}]},{"@type":"WebSite","@id":"https:\/\/www.codemotion.com\/magazine\/#website","url":"https:\/\/www.codemotion.com\/magazine\/","name":"Codemotion Magazine","description":"We code the future. Together","publisher":{"@id":"https:\/\/www.codemotion.com\/magazine\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codemotion.com\/magazine\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codemotion.com\/magazine\/#organization","name":"Codemotion","url":"https:\/\/www.codemotion.com\/magazine\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/logo\/image\/","url":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/11\/codemotionlogo.png","contentUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/11\/codemotionlogo.png","width":225,"height":225,"caption":"Codemotion"},"image":{"@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Codemotion.Italy\/","https:\/\/x.com\/CodemotionIT"]},{"@type":"Person","@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/person\/0ee64d200a6d244e92d780fa0258094e","name":"Chukwudi Golden","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/df8800832dada5055a69da0d903cd2a2d3f8e777c4cc9bbbd44d4952befae3fc?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/df8800832dada5055a69da0d903cd2a2d3f8e777c4cc9bbbd44d4952befae3fc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/df8800832dada5055a69da0d903cd2a2d3f8e777c4cc9bbbd44d4952befae3fc?s=96&d=mm&r=g","caption":"Chukwudi Golden"},"url":"https:\/\/www.codemotion.com\/magazine\/author\/chukwudi-golden\/"}]}},"featured_image_src":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post--600x400.jpg","featured_image_src_square":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post--600x600.jpg","author_info":{"display_name":"Chukwudi Golden","author_link":"https:\/\/www.codemotion.com\/magazine\/author\/chukwudi-golden\/"},"uagb_featured_image_src":{"full":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post-.jpg",1600,900,false],"thumbnail":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post--150x150.jpg",150,150,true],"medium":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post--300x169.jpg",300,169,true],"medium_large":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post--768x432.jpg",768,432,true],"large":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post--1024x576.jpg",1024,576,true],"1536x1536":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post--1536x864.jpg",1536,864,true],"2048x2048":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post-.jpg",1600,900,false],"small-home-featured":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post-.jpg",100,56,false],"sidebar-featured":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post--180x128.jpg",180,128,true],"genesis-singular-images":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post--896x504.jpg",896,504,true],"archive-featured":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post--400x225.jpg",400,225,true],"gb-block-post-grid-landscape":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post--600x400.jpg",600,400,true],"gb-block-post-grid-square":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2023\/04\/Minimal-colorful-quote-twitter-post--600x600.jpg",600,600,true]},"uagb_author_info":{"display_name":"Chukwudi Golden","author_link":"https:\/\/www.codemotion.com\/magazine\/author\/chukwudi-golden\/"},"uagb_comment_info":0,"uagb_excerpt":"Introduction Let&#8217;s take a look at some key concepts to fully understand Bun runtime: the setting in which JavaScript code executes is referred to as the JavaScript runtime. It provides the event loop, memory allocation, and garbage collection architecture required to run JavaScript code. Using a runtime environment like Node.js, JavaScript code can be run&#8230;&hellip;","lang":"en","_links":{"self":[{"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/posts\/20773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/users\/163"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/comments?post=20773"}],"version-history":[{"count":9,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/posts\/20773\/revisions"}],"predecessor-version":[{"id":20785,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/posts\/20773\/revisions\/20785"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/media\/20779"}],"wp:attachment":[{"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/media?parent=20773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/categories?post=20773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/tags?post=20773"},{"taxonomy":"collections","embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/collections?post=20773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}