• Stars
    star
    72
  • Rank 438,337 (Top 9 %)
  • Language
    Scala
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Benchmarks: write in Scala or JS, run in your browser. Live demo:

scalajs-benchmark

Build Status

Benchmarks: write in Scala or JS, run in your browser.

See an online demo here: https://japgolly.github.io/scalajs-benchmark/.
The tiny source code is here: gh-pages/demo.

Changelogs — Latest: 0.10.0.

How do I use it?

  1. Include scalajs-benchmark as a dependency in your Scala.JS project.
libraryDependencies += "com.github.japgolly.scalajs-benchmark" %%% "benchmark" % "0.10.0"
  1. You write benchmarks.
import japgolly.scalajs.benchmark._
import japgolly.scalajs.benchmark.gui._

object Example {
  val suite = GuiSuite(
    Suite("Example Benchmarks")(

      // Benchmark #1
      Benchmark("foreach") {
        var s = Set.empty[Int]
        (1 to 100) foreach (s += _)
        s
      },

      // Benchmark #2
      Benchmark("fold") {
        (1 to 100).foldLeft(Set.empty[Int])(_ + _)
      }
    )
  )
}

(Hey, can you make that 1 to 100 configurable in the GUI? You sure can.)

  1. Add a tiny loader HTML like this.

  2. Create a main app and point scalajs-benchmark at your suite of benchmarks.

import org.scalajs.dom.document
import japgolly.scalajs.benchmark.gui.BenchmarkGUI

object Main {

  def main(args: Array[String]) = {
    val body = document getElementById "body"
    BenchmarkGUI.renderSuite(body)(Example.suite)
  }
}

If you have a library of different benchmarks, instead of using renderSuite, you use renderMenu to create an app that lets the user navigate the library and run benchmarks.

Example:

BenchmarkGUI.renderMenu(body)(
  suites.example.Examples.all,
  suites.scala.all)
  1. Compile; run in browser. Done.

Support

If you like what I do —my OSS libraries, my contributions to other OSS libs, my programming blog— and you'd like to support me, more content, more lib maintenance, please become a patron! I do all my OSS work unpaid so showing your support will make a big difference.


Note: This is not affiliated with the official Scala.JS project; it's just named to be informative rather than interesting.

More Repositories

1

scalajs-react

Facebook's React on Scala.JS
Scala
1,644
star
2

svg-android

Fork of svg-android +SVN history +Maven +more
Java
568
star
3

scalacss

Super type-safe CSS for Scala and Scala.JS.
Scala
339
star
4

scala-graal

Make usage of Graal features easy and safe from Scala. Also features Scala-based React SSR.
Scala
194
star
5

nyaya

Random Data Generation and/or Property Testing in Scala & Scala.JS.
Scala
185
star
6

test-state

Scala Test-State.
Scala
141
star
7

clear-config

Scala FP configuration library with a focus on runtime clarity
Scala
140
star
8

univeq

Safer universal equivalence (==) for Scala.
Scala
59
star
9

learning

Scala
46
star
10

setup-everything-scala

GitHub Action to prepare the environment for Scala & Scala.JS dev and testing
Scala
40
star
11

mr.boilerplate

Online app to generate Scala boilerplate
Scala
33
star
12

microlibs-scala

Scala
26
star
13

tla2json

Convert TLA+ output (and values) into JSON
Scala
24
star
14

webtamp

Asset bundler. Companion to bundlers like Webpack.
TypeScript
20
star
15

webapp-util

Scala Webapp Utilities
Scala
17
star
16

scala-restructure

Scala
9
star
17

misc

4
star
18

archlinux-packages

Shell
2
star
19

setup-scalajs

GitHub Action to prepare the environment for Scala.JS dev and testing
JavaScript
2
star
20

rubyprof-test

Ruby
1
star
21

setup-scala-util

GitHub Action to add Scala utilities to the PATH
Scala
1
star
22

ruby-corvid

Ruby
1
star
23

astacus

Ruby
1
star
24

autotag2

Years-old app to tag MP3s.
Ruby
1
star
25

android-test-utils

Java
1
star
26

text_to_diagram

Generate software diagrams (ERDs, DFDs, etc) using text files, rather than spending hours combating visual tools.
Ruby
1
star
27

ruby-golly-utils

Ruby
1
star