Artifact:   On the Cost of Type-Tag Soundness
1 Using the Datasets
2 Reference
x-axis
y-axis
x-axes
y-axes
SNAPL-2015-URL
mypy
PEP-483
PEP-484
TPPBS
time.process_  time
DLS-2014-BENCHMARK-NAMES
POPL-2017-BENCHMARK-NAMES
DLS-2017-BENCHMARK-NAMES
EXHAUSTIVE-BENCHMARKS
VALIDATE-BENCHMARKS
SAMPLE-BENCHMARKS
MAX-OVERHEAD
NUM-EXHAUSTIVE-BENCHMARKS
NUM-VALIDATE-SAMPLES
NUM-NEW-SAMPLES
NUM-ITERATIONS
SAMPLE-RATE
NUM-SAMPLE-TRIALS
NUM-BETTER-WITH-TYPES
BENCHMARKS-WITH-FIRST-CLASS-FUNCTIONS
PYTHON
EXACT-RUNTIME-XSPACE
u/  p-ratio
t/  u-ratio
t/  p-ratio
sra
etal
bm
bm*
url
generate-bibliography
~cite
citet
bm-desc
exact-runtime-category
percent-slower-than-typed
definition
defn
lib-desc
$
authors
authors*
deliverable
approximation
exact
id
Integer->word
parag
python
pythonexternal
pythoninline
sc
sf
Section-ref
section-ref
2.1 Static Benchmark Information
benchmark-info?
benchmark->name
benchmark->module*
benchmark->src
benchmark->num-modules
benchmark->num-configurations
benchmark->max-configuration
benchmark->sloc
benchmark->karst-data
benchmark->sample-data
benchmark->python-data
benchmark->karst-retic-untyped
benchmark->karst-retic-typed
all-benchmarks
configuration?
configuration->natural
natural->configuration
configuration<?
string->configuration
configuration->string
benchmark-info->python-info?
2.2 Python Data
python-info
module-info
class-info
function-info
field-info
python-path?
python-sloc
python-info->max-configuration
benchmark-dir->python-info
python-info->module*
python-info->num-modules
python-info->function*
python-info->num-functions
python-info->class*
python-info->num-classes
python-info->method*
python-info->num-methods
python-info->domain*
python-info->num-parameters
python-info->return*
python-info->num-returns
python-info->field*
python-info->num-fields
python-info->all-types
python-info->num-types
2.3 Reticulated Performance Data
performance-info?
performance-info->name
benchmark->performance-info
python-runtime
untyped-runtime
typed-runtime
num-configurations
num-types
overhead
min-overhead
max-overhead
mean-overhead
deliverable
typed/  python-ratio
typed/  retic-ratio
untyped/  python-ratio
make-D-deliverable
count-configurations
filter-time*
performance-info-has-karst-data?
performance-info->sample*
performance-info%sample
unzip-karst-data
performance-info-src
line->configuration-string
fold/  karst
2.4 Generating Plots
overhead-plot
exact-runtime-plot
validate-samples-plot
samples-plot
*LEGEND-VSPACE*
*LEGEND-HSPACE*
*OVERHEAD-PLOT-WIDTH*
*OVERHEAD-PLOT-HEIGHT*
*OVERHEAD-FONT-FACE*
*OVERHEAD-FONT-SCALE*
*OVERHEAD-LABEL?*
*OVERHEAD-LINE-COLOR*
*OVERHEAD-LINE-STYLE*
*OVERHEAD-LINE-WIDTH*
*OVERHEAD-MAX*
*OVERHEAD-SHOW-RATIO*
*OVERHEAD-SAMPLES*
*FONT-SIZE*
*CACHE-SIZE*
*POINT-SIZE*
*POINT-ALPHA*
*CONFIGURATION-X-JITTER*
*OVERHEAD-FREEZE-BODY*
*CONFIDENCE-LEVEL*
*INTERVAL-ALPHA*
*RATIO-DOT-SYM*
*RATIO-DOT-SIZE*
*RATIO-DOT-COLOR*
*TYPED/  PYTHON-RATIO-XTICK?*
2.5 Rendering Figures
render-overhead-plot*
render-exact-runtime-plot*
render-static-information
render-ratios-table
render-samples-plot*
render-validate-samples-plot*
*PLOT-HEIGHT*
*CACHE-SUFFIX*
*SINGLE-COLUMN?*
get-ratios-table
ratios-table-row
ratios-row-retic/  python
ratios-row-typed/  retic
ratios-row-typed/  python
2.6 System Calls
shell
md5sum
2.7 Utility Functions
tab-split
tab-join
path-string->string
ensure-directory
rnd
pct
log2
file-remove-extension
add-commas
save-pict
columnize
force/  cpu-time
natural->bitstring
bitstring->natural
count-zero-bits
integer->word
8.12

Artifact: On the Cost of Type-Tag Soundness🔗ℹ

This package supplements our paper On the Cost of Type-Tag Soundness. It contains code to process our datasets and generate the submitted paper.

Local copy: http://www.ccs.neu.edu/home/types/resources/pdf/gm-pepm-2018.pdf

Source code: https://github.com/nuprl/retic_performance

Note: the code in this package assumes that certain relative paths exist. For example, it assumes the Karst datasets are in the folder "../data/karst" relative to the source for the gm-pepm-2018 package.

1 Using the Datasets🔗ℹ

The gm-pepm-2018 package includes command-line tools for interacting with a dataset.

These tools are defined in modules under the "script/" folder and are declared in the "info.rkt" file for gm-pepm-2018.

Example: to generate an overhead plot for Espionage, run:

raco rp-plot Espionage

For more information about a command CMD, run:

raco CMD --help

2 Reference🔗ℹ

The gm-pepm-2018 language provides the reader from scribble/base and all exports from the gm-pepm-2018 module.

Other modules in the collection process the Reticulated benchmarks and the datasets. The modules are documented in the sections below.

syntax

x-axis

syntax

y-axis

syntax

x-axes

syntax

y-axes

Render the phrase x-axis, etc.

syntax

SNAPL-2015-URL

syntax

mypy

syntax

PEP-483

syntax

PEP-484

syntax

TPPBS

syntax

time.process_time

URLs and hyperlinks.

Lists of benchmark names, organized by source.

Lists of benchmarks, organized by dataset type.

Various constants for the paper / experiment / analysis.

Maximum distance between a point on an exact runtime plot and the (integer) number of types in the configuration that the point represents.

syntax

u/p-ratio

syntax

t/u-ratio

syntax

t/p-ratio

Format the name of a performance ratio.

syntax

sra

Format the phrase simple random approximation. No typos!

syntax

etal

Format et al. with proper spacing.

procedure

(bm str)  element?

  str : string?
Render the name of a benchmark program.

procedure

(bm* str ...)  element?

  str : string?
Render a sequence of benchmark names.

procedure

(url str)  element?

  str : string?
Similar to the url procedure from scribble/base, but does some extra formatting.

procedure

(generate-bibliography)  part?

Generate the bibliography. Call this at the end of the document. See also scriblib/autobib.

procedure

(~cite b ...)  element?

  b : bib?
Format a citation. See also scriblib/autobib.

procedure

(citet b)  element?

  b : bib?
Format a noun-style citation. See also scriblib/autobib.

procedure

(bm-desc title author url lib description ...)  element?

  title : string?
  author : pre-content?
  url : element?
  lib : (listof pre-content?)
  description : pre-content?
Formats data describing a benchmark program.

procedure

(exact-runtime-category cat-name    
  names    
  make-description)  element?
  cat-name : string?
  names : (listof string?)
  make-description : (-> string? pre-content?)
Format a description for a class of plots. The class is named cat-name and consists of the plots for the benchmarks names. The function make-description accepts a string describing the number of names and returns an element that further describes the category.

procedure

(percent-slower-than-typed name)  integer?

  name : string?
Count the percentage of configurations of benchmark name that run slower than the fully-typed configuration.

procedure

(definition term description ...)  paragraph?

  term : string?
  description : string?
Format a definition for term with content description ....

procedure

(defn term)  element?

  term : string?
Format a reference to a defined term.

procedure

(lib-desc name description ...)  pre-content?

  name : string?
  description : string?
Format the name of a Python library and a description of how the library was used.

procedure

($ str ...)  element?

  str : string?
Pass the given content to LaTeX math mode.

procedure

(authors str ...)  element?

  str : string?

procedure

(authors* strs)  element?

  strs : (listof string?)
Format a list of author names.

procedure

(deliverable D)  element?

  D : (or/c pre-content? real?)
Format D-deliverable.

procedure

(approximation r s pct)  element?

  r : (or/c pre-content? real?)
  s : (or/c pre-content? real?)
  pct : (or/c pre-content? real?)
Format pct%-r,s-approximation.

procedure

(exact str ...)  element?

  str : string?
Pass the given content directly to LaTeX.

procedure

(id x)  pre-content?

  x : any/c
Same as ~a.

procedure

(Integer->word n)  string?

  n : integer?
Format the given integer as a capitalized word in English.

procedure

(parag title)  element?

  title : string?
Format title as the name of a paragraph.

procedure

(python code ...)  element?

  code : string?
Format a block of Python code.

procedure

(pythonexternal filename)  element?

  filename : string?
Format the contents of the file filename as a block of Python code.

procedure

(pythoninline code ...)  element?

  code : string?
Format one line of Python code.

procedure

(sc str ...)  element?

  str : string?

procedure

(sf str ...)  element?

  str : string?
Format small caps (sc) and sans-serif (sf) text.

procedure

(Section-ref tag)  element?

  tag : string?

procedure

(section-ref tag)  element?

  tag : string?
Format a reference to a section.

2.1 Static Benchmark Information🔗ℹ

A benchmark program consists of:
  • a set of fully-typed Python modules;

  • other Python modules and data files.

The "other modules" may be typed or untyped; the point is that all configurations use identical copies of these modules.

API to the benchmark programs

procedure

(benchmark-info? v)  boolean?

  v : any/c
Predicate for benchmark information.

procedure

(benchmark->name bm)  string?

  bm : benchmark-info?
Get the name from a benchmark.

procedure

(benchmark->module* bm)  (listof string?)

  bm : benchmark-info?
Get the names of the Python modules in the benchmark.

procedure

(benchmark->src bm)  path-string?

  bm : benchmark-info?
Return a path to the directory that contains the benchmark.

procedure

(benchmark->num-modules bm)  natural?

  bm : benchmark-info?
Count the number of modules in the benchmark.

procedure

(benchmark->num-configurations bm)  natural?

  bm : benchmark-info?
Count the number of configurations in the benchmark.

procedure

(benchmark->max-configuration bm)  configuration?

  bm : benchmark-info?
Return a configuration that is larger than any configuration in the benchmark, i.e. "max plus one".

procedure

(benchmark->sloc bm)  natural?

  bm : benchmark-info?
Count the source-lines-of-code in the benchmark. Uses David A. Wheeler’s sloccount.

procedure

(benchmark->karst-data bm)  (or/c #f path-string?)

  bm : benchmark-info?

procedure

(benchmark->sample-data bm)  (or/c #f path-string?)

  bm : benchmark-info?
Return a path to the benchmark’s Karst data, if such data exists. The function benchmark->karst-data finds the exhaustive data; the function benchmark->sample-data finds data for randomly-sampled configurations. }

procedure

(benchmark->python-data bm)  (listof real?)

  bm : benchmark-info?

procedure

(benchmark->karst-retic-untyped bm)  (listof real?)

  bm : benchmark-info?

procedure

(benchmark->karst-retic-typed bm)  (listof real?)

  bm : benchmark-info?
Return a list of Python, fully-untyped, or fully-typed runtimes. If such data does not exist, return an arbitary list.

The idea with the "arbitrary" list is to return data that suffices to build an "obviously wrong" plot. Now that the paper is finished, we could error if the data does not exist.

procedure

(all-benchmarks)  (listof benchmark-info?)

Return a list of all known benchmarks.

procedure

(configuration? v)  boolean?

  v : any/c
A configuration is one way of mixing typed and untyped code in a benchmark. This predicate returns #true when given an identifier for a configuration.

procedure

(configuration->natural bm cfg)  natural?

  bm : benchmark-info?
  cfg : configuration?

procedure

(natural->configuration bm n)  configuration?

  bm : benchmark-info?
  n : natural?

procedure

(configuration<? cfg0 cfg1)  boolean?

  cfg0 : configuration?
  cfg1 : configuration?
These functions define a bijection between configurations and natural numbers, and consequently a total order.

procedure

(string->configuration str)  configuration?

  str : string?

procedure

(configuration->string cfg)  string?

  cfg : configuration?
Map between configurations and strings.

procedure

(benchmark-info->python-info? bm)  python-info?

  bm : benchmark-info?
Return low-level data about the Python modules in a benchmark.

2.2 Python Data🔗ℹ

The Python script "gm-pepm-2018/script/explode_module.py" extracts information about the structure of a Python module (e.g., number of classes).

API to Python syntax trees

struct

(struct python-info (name module?))

  name : symbol?
  module? : (listof module-info?)

struct

(struct module-info (name function?))

  name : symbol?
  function? : (listof function-info?)

struct

(struct class-info (name field* method*))

  name : symbol?
  field* : (listof field-info?)
  method* : (listof function-info?)

struct

(struct function-info (name dom* cod))

  name : symbol?
  dom* : (listof field-info?)
  cod : (or/c string? #f)

struct

(struct field-info (name type))

  name : symbol?
  type : string?
Structs for Python syntax. Note that nested classes and nested functions are not supported.

procedure

(python-path? v)  boolean?

  v : any/c
Return #true for path strings that end with the suffix ".py".

procedure

(python-sloc ps)  natural?

  ps : python-path?
Count the source-lines-of-code in a Python module.

procedure

(python-info->max-configuration py)  configuration?

  py : python-info?
Return the max-plus-one configuration for a Python program.

procedure

(benchmark-dir->python-info d)  python-info?

  d : is-benchmark-directory?
Parse the Python files in a directory.

procedure

(python-info->module* py)  (listof string?)

  py : python-info?

procedure

(python-info->num-modules py)  natural?

  py : python-info?

procedure

(python-info->function* py)  (listof string?)

  py : python-info?

procedure

(python-info->num-functions py)  natural?

  py : python-info?

procedure

(python-info->class* py)  (listof string?)

  py : python-info?

procedure

(python-info->num-classes py)  natural?

  py : python-info?

procedure

(python-info->method* py)  (listof string?)

  py : python-info?

procedure

(python-info->num-methods py)  natural?

  py : python-info?

procedure

(python-info->domain* py)  (listof (listof field-info?))

  py : python-info?

procedure

(python-info->num-parameters py)  natural?

  py : python-info?

procedure

(python-info->return* py)  (listof string?)

  py : python-info?

procedure

(python-info->num-returns py)  natural?

  py : python-info?

procedure

(python-info->field* py)  (listof field-info?)

  py : python-info?

procedure

(python-info->num-fields py)  natural?

  py : python-info?

procedure

(python-info->all-types py)  (set/c (or/c #f string?))

  py : python-info?

procedure

(python-info->num-types py)  natural?

  py : python-info?
For querying a Python AST.

2.3 Reticulated Performance Data🔗ℹ

API to performance data

procedure

(performance-info? v)  boolean?

  v : any/c
Predicate for performance information.

procedure

(performance-info->name pi)  symbol?

  pi : performance-info?
Return the name of the underlying benchmark.

procedure

(benchmark->performance-info bm)  performance-info?

  bm : benchmark-info?
Collect performance information for the given benchmark.

procedure

(python-runtime pi)  real?

  pi : performance-info?

procedure

(untyped-runtime pi)  real?

  pi : performance-info?

procedure

(typed-runtime pi)  real?

  pi : performance-info?
Get extreme running times.

procedure

(num-configurations pi)  natural?

  pi : performance-info?
Count the number of configurations in the underlying benchmark.

procedure

(num-types pi)  natural?

  pi : performance-info?
Count the maximum number of type annotations in the underlying benchmark.

procedure

(overhead pi r)  real?

  pi : performance-info?
  r : real?
Compute the overhead of the given number r relative to the Python running time.

procedure

(min-overhead pi)  real?

  pi : performance-info?

procedure

(max-overhead pi)  real?

  pi : performance-info?

procedure

(mean-overhead pi)  real?

  pi : performance-info?
Find the minumum / maximum / mean performance overheads, across all configurations.

procedure

(deliverable D)  (-> performance-info? natural?)

  D : real?
Return a function that counts the number of D-deliverable configurations.

procedure

(typed/python-ratio pi)  real?

  pi : performance-info?

procedure

(typed/retic-ratio pi)  real?

  pi : performance-info?

procedure

(untyped/python-ratio pi)  real?

  pi : performance-info?
Compute performance ratios.

procedure

(make-D-deliverable D pi)  (-> real? boolean?)

  D : real?
  pi : performance-info?
Return a predicate on running times; the predicate returns #true for running times that are at most D times slower than the Python running time.

procedure

(count-configurations pi good?)  natural?

  pi : performance-info?
  good? : (-> real? boolean?)
Count the number of configurations that satisfy the predicate good?.

procedure

(filter-time* pi good?)  (listof real?)

  pi : performance-info?
  good? : (-> real? boolean?)
Return the mean running times for configurations whose mean running time satisfies the given predicate.

procedure

(performance-info-has-karst-data? pi)  boolean?

  pi : performance-info?
Returns #true if pi has exhaustive Karst data.

procedure

(performance-info->sample* pi)

  (cons/c natural? (listof path-string?))
  pi : performance-info?
Return a pair with (1) sample size and (2) paths to sample data.

procedure

(performance-info%sample pi ps)  performance-info?

  pi : performance-info?
  ps : path-string?
Return performance information about the given file of sampled data.

procedure

(unzip-karst-data ps)  (or/c #f path-string?)

  ps : path-string?
Unzip the Karst data at the given gzip’d file.

procedure

(performance-info-src pi)  path-string?

  pi : performance-info?
Return a path to (exhaustive) Karst data.

procedure

(line->configuration-string ln)  string?

  ln : string?
Parse a line of Karst data to a string representing a configuration.

procedure

(fold/karst input #:f f #:init init)  A

  input : (or/c path-string? performance-info?)
  f : (-> A configuration? natural? (listof real?) A)
  init : A
Fold (left) over Karst data.

2.4 Generating Plots🔗ℹ

for building plots

procedure

(overhead-plot pi)  pict?

  pi : performance-info?

procedure

(exact-runtime-plot pi)  pict?

  pi : performance-info?

procedure

(validate-samples-plot pi)  pict?

  pi : performance-info?

procedure

(samples-plot pi)  pict?

  pi : performance-info?
Plot performance data.

parameter

(*LEGEND-VSPACE*)  natural?

(*LEGEND-VSPACE* n)  void?
  n : natural?
 = 10

parameter

(*LEGEND-HSPACE*)  natural?

(*LEGEND-HSPACE* n)  void?
  n : natural?
 = 20

parameter

(*OVERHEAD-PLOT-WIDTH*)  natural?

(*OVERHEAD-PLOT-WIDTH* n)  void?
  n : natural?
 = 600

parameter

(*OVERHEAD-PLOT-HEIGHT*)  natural?

(*OVERHEAD-PLOT-HEIGHT* n)  void?
  n : natural?
 = 300

parameter

(*OVERHEAD-FONT-FACE*)  string?

(*OVERHEAD-FONT-FACE* f)  void?
  f : string?
 = "bold"

parameter

(*OVERHEAD-FONT-SCALE*)  (>=/c 0)

(*OVERHEAD-FONT-SCALE* n)  void?
  n : (>=/c 0)
 = 0.03

parameter

(*OVERHEAD-LABEL?*)  boolean?

(*OVERHEAD-LABEL?* lbl?)  void?
  lbl? : boolean?
 = #f

parameter

(*OVERHEAD-LINE-COLOR*)  plot-color/c

(*OVERHEAD-LINE-COLOR* c)  void?
  c : plot-color/c
 = 3

parameter

(*OVERHEAD-LINE-STYLE*)  plot-pen-style/c

(*OVERHEAD-LINE-STYLE* s)  void?
  s : plot-pen-style/c
 = 'solid

parameter

(*OVERHEAD-LINE-WIDTH*)  (>=/c 0)

(*OVERHEAD-LINE-WIDTH* lw)  void?
  lw : (>=/c 0)
 = 1

parameter

(*OVERHEAD-MAX*)  natural?

(*OVERHEAD-MAX* om)  void?
  om : natural?
 = 10

parameter

(*OVERHEAD-SHOW-RATIO*)  (or/c boolean? symbol?)

(*OVERHEAD-SHOW-RATIO* sr)  void?
  sr : (or/c boolean? symbol?)
 = #t

parameter

(*OVERHEAD-SAMPLES*)  natural?

(*OVERHEAD-SAMPLES* os)  void?
  os : natural?
 = 20

parameter

(*FONT-SIZE*)  natural?

(*FONT-SIZE* fs)  void?
  fs : natural?
 = 10

parameter

(*CACHE-SIZE*)  natural?

(*CACHE-SIZE* cs)  void?
  cs : natural?
 = (expt 2 16)

parameter

(*POINT-SIZE*)  natural?

(*POINT-SIZE* ps)  void?
  ps : natural?
 = 3

parameter

(*POINT-ALPHA*)  (>=/c 0)

(*POINT-ALPHA* a)  void?
  a : (>=/c 0)
 = 0.4

parameter

(*CONFIGURATION-X-JITTER*)  real?

(*CONFIGURATION-X-JITTER* j)  void?
  j : real?
 = 0.4

parameter

(*OVERHEAD-FREEZE-BODY*)  boolean?

(*OVERHEAD-FREEZE-BODY* f?)  void?
  f? : boolean?
 = #f

parameter

(*CONFIDENCE-LEVEL*)  (between/c 0 100)

(*CONFIDENCE-LEVEL* c)  void?
  c : (between/c 0 100)
 = 95

parameter

(*INTERVAL-ALPHA*)  (>=/c 0)

(*INTERVAL-ALPHA* r)  void?
  r : (>=/c 0)
 = 1

parameter

(*RATIO-DOT-SYM*)  point-sym/c

(*RATIO-DOT-SYM* s)  void?
  s : point-sym/c
 = 'plus

parameter

(*RATIO-DOT-SIZE*)  natural?

(*RATIO-DOT-SIZE* n)  void?
  n : natural?
 = 8

parameter

(*RATIO-DOT-COLOR*)  string?

(*RATIO-DOT-COLOR* c)  void?
  c : string?
 = "firebrick"

parameter

(*TYPED/PYTHON-RATIO-XTICK?*)  boolean?

(*TYPED/PYTHON-RATIO-XTICK?* t?)  void?
  t? : boolean?
 = #f
Parameters to control ANY aspect of your plots. Ha Ha Ha.

2.5 Rendering Figures🔗ℹ

 (require gm-pepm-2018/script/render) package: gm-pepm-2018

procedure

(render-overhead-plot* bm*)  pict?

  bm* : (listof benchmark-info?)

procedure

(render-exact-runtime-plot* bm*)  pict?

  bm* : (listof benchmark-info?)

procedure

(render-static-information bm*)  table?

  bm* : (listof benchmark-info?)

procedure

(render-ratios-table bm*)  table?

  bm* : (listof benchmark-info?)

procedure

(render-samples-plot* bm*)  pict?

  bm* : (listof benchmark-info?)

procedure

(render-validate-samples-plot* bm*)  pict?

  bm* : (listof benchmark-info?)
Render figures for the given benchmarks. These procedures yield plots and tables similar to those in the paper.

parameter

(*PLOT-HEIGHT*)  exact-integer?

(*PLOT-HEIGHT* h)  void?
  h : exact-integer?
Determines the height of plots.

parameter

(*CACHE-SUFFIX*)  string?

(*CACHE-SUFFIX* s)  void?
  s : string?
Determines the suffix of cache files. See with-cache.

parameter

(*SINGLE-COLUMN?*)  boolean?

(*SINGLE-COLUMN?* single?)  void?
  single? : boolean?
When #true, render plots in single-column format. (You will want to manually change the enclosing figure* to a figure. If you don’t know what I mean, then just don’t change this parameter.)

procedure

(get-ratios-table bm*)  list?

  bm* : (listof benchmark-info?)

procedure

(ratios-table-row rt)  list?

  rt : list?

procedure

(ratios-row-retic/python rr)  string?

  rr : list?

procedure

(ratios-row-typed/retic rr)  string?

  rr : list?

procedure

(ratios-row-typed/python rr)  string?

  rr : list?
Helpers for reading performance ratios. The idea is, build the table once and read it many times for data.

2.6 System Calls🔗ℹ

A system call interface

procedure

(shell program args)  string?

  program : path-string?
  args : (or/c path-string? (listof path-string?))
Invoke the given program with the given command-line arguemnts, return the program’s standard output.

procedure

(md5sum ps)  string?

  ps : path-string?
Compute an MD5 hash for the given file. See also openssl/md5.

2.7 Utility Functions🔗ℹ

Miscellaneous utilities

procedure

(tab-split str)  (listof string?)

  str : string?
Split a string by tab characters. See also string-split.

procedure

(tab-join str*)  string?

  str* : (listof string?)
Join a list of strings using tab characters. See also string-join.

procedure

(path-string->string ps)  string?

  ps : path-string?
Convert a path or string to a string.

This function is surprisingly useful in untyped code, and extremely useful in typed code.

procedure

(ensure-directory d)  void?

  d : path-string?
Create the directory d, unless it already exists.

procedure

(rnd r)  string?

  r : real?
Round a number to 2 decimal places.

procedure

(pct numerator denominator)  real?

  numerator : real?
  denominator : real?
Return (* 100 (/ numerator denominator)).

procedure

(log2 n)  natural?

  n : natural?
Return the log base 2 of a power of 2.

procedure

(file-remove-extension ps)  path-string?

  ps : path-string?
Remove the extension from a filename.

procedure

(add-commas r)  string?

  r : real?
Format a real number to a string with commas in the normal places (between every 3 digits).

procedure

(save-pict ps p)  boolean?

  ps : path-string?
  p : pict?
Save the given pict to the given path string.

procedure

(columnize vals n)  (listof list?)

  vals : list?
  n : natural?
Arrange the given values into n lists of almost-equal length.

procedure

(force/cpu-time thunk)  
any/c natural?
  thunk : (-> any/c)
Execute the given thunk. Return the result and the elapsed CPU time. See also time-apply.

procedure

(natural->bitstring n #:pad k)  string?

  n : natural?
  k : natural?

procedure

(bitstring->natural s)  natural?

  s : string?
A bijection between natural numbers and k-bit strings of "1" and "0".

procedure

(count-zero-bits s)  natural?

  s : string?
Count the number of 0 characters in a string.

procedure

(integer->word n [#:title? title?])  string?

  n : integer?
  title? : any/c = #f
Convert a small integer to an English word. When title? is non-#f, return a capitalized word.