Skip to content

Presence of '\'' in the benchmark's name breaks the html report #202

@jhrcek

Description

@jhrcek

When I use apostrophe character in benchmark's name, all the charts in the html report are broken.

Steps to reproduce

  1. use apostrophe in benchmark's name:
module Main where

import Criterion
import Criterion.Main

main :: IO ()
main = defaultMain
    [ env (return ()) $
       \ ~() -> bgroup "Jan's benchmarks" [bench "dummy" $ nf id ()]
    ]
  1. compile the file and run it, enabling html report generation:

./mybench --output report.html

  1. Open the resulting report in the browser (I use latest google-chrom version 69)

Actual result:
none of the charts is displayed, and browser's console shows this error
Uncaught SyntaxError: Unexpected identifier
Inspecting the report more closely the error is coming from this piece of code generated in the report based on benchmark's name:

 var ylabels = [[-0,'<a href="#b0">Jan's benchmarks/dummy</a>'],];

Literal inclusion of benchmark's name into the javascript apparently leads to premature finish of the string literal, causing the sytax error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions