Skip to content

Commit

Permalink
Add latex performance chart
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 12, 2021
1 parent 9060ac3 commit 3d5c7a5
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository = "https://github.com/dtolnay/dtoa"
documentation = "https://docs.rs/dtoa"
categories = ["value-formatting"]
readme = "README.md"
exclude = ["performance.png"]
exclude = ["performance.png", "chart/**"]
edition = "2018"

[package.metadata.docs.rs]
Expand Down
7 changes: 7 additions & 0 deletions chart/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.aux
*.fdb_latexmk
*.fls
*.log
*.pdf
*.png
*.svg
80 changes: 80 additions & 0 deletions chart/performance.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{sansmath}
\pgfplotsset{compat=1.16}
\definecolor{dtoa}{HTML}{3366FF}
\definecolor{std}{HTML}{949494}
\definecolor{bg}{HTML}{CFCFCF}
\begin{document}
\pagecolor{white}
\begin{tikzpicture}
\edef\entries{
"$0.0$",
"$0.1234$",
"$2.718281828459045$",
"$1.7976931348623157e308$",
}
\begin{axis}[
width=5in,
height=3.5in,
ybar,
ymin=0,
bar width=24pt,
enlarge x limits={abs=39pt},
ylabel={nanos for one call to write},
legend style={
anchor=north west,
at={(0.025,0.975)},
legend columns=1,
draw=none,
fill=none,
},
legend entries={
dtoa::Buffer::new().format(value)\\
std::write!(\&mut buf, ``\{\}'', value)\\
},
legend cell align=left,
xtick={-0.5,0.5,1.5,2.5,3.5,4.5},
xticklabels={},
xtick pos=left,
visualization depends on={y \as \rawy},
every node near coord/.append style={
shift={(axis direction cs:0,-\rawy/2)},
rotate=90,
anchor=center,
font=\sansmath\sffamily,
},
axis background/.style={fill=bg},
tick label style={font=\sansmath\sffamily},
every axis label={font=\sansmath\sffamily},
legend style={font=\sansmath\sffamily},
label style={font=\sansmath\sffamily},
]
\addplot[
black,
fill=dtoa,
area legend,
nodes near coords={},
] coordinates {
(0, 2)
(1, 36)
(2, 50)
(3, 72)
};
\addplot[
black,
fill=std,
area legend,
nodes near coords=\pgfmathsetmacro{\input}{{\entries}[\coordindex]}\input,
] coordinates {
(0, 20)
(1, 66)
(2, 84)
(3, 112)
};
\end{axis}
\pgfresetboundingbox\path
(current axis.south west) -- ++(-0.44in,-0.09in)
rectangle (current axis.north east) -- ++(0.05in,0.05in);
\end{tikzpicture}
\end{document}
Binary file modified performance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3d5c7a5

Please sign in to comment.