-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c378914
commit 57c6a7d
Showing
31 changed files
with
831 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,43 @@ | ||
import { run, bench } from "mitata"; | ||
import { run, bench, group } from "mitata"; | ||
import { gzipSync, gunzipSync } from "bun"; | ||
|
||
const data = new TextEncoder().encode("Hello World!".repeat(9999)); | ||
const data = await Bun.file(require.resolve("@babel/standalone/babel.min.js")).arrayBuffer(); | ||
|
||
const compressed = gzipSync(data); | ||
|
||
bench(`roundtrip - "Hello World!".repeat(9999))`, () => { | ||
gunzipSync(gzipSync(data)); | ||
const libraries = ["zlib"]; | ||
if (Bun.semver.satisfies(Bun.version.replaceAll("-debug", ""), ">=1.1.21")) { | ||
libraries.push("libdeflate"); | ||
} | ||
const options = { library: undefined }; | ||
const benchFn = (name, fn) => { | ||
if (libraries.length > 1) { | ||
group(name, () => { | ||
for (const library of libraries) { | ||
bench(library, () => { | ||
options.library = library; | ||
fn(); | ||
}); | ||
} | ||
}); | ||
} else { | ||
options.library = libraries[0]; | ||
bench(name, () => { | ||
fn(); | ||
}); | ||
} | ||
}; | ||
|
||
benchFn(`roundtrip - @babel/standalone/babel.min.js`, () => { | ||
gunzipSync(gzipSync(data, options), options); | ||
}); | ||
|
||
bench(`gzipSync("Hello World!".repeat(9999)))`, () => { | ||
gzipSync(data); | ||
benchFn(`gzipSync(@babel/standalone/babel.min.js`, () => { | ||
gzipSync(data, options); | ||
}); | ||
|
||
bench(`gunzipSync("Hello World!".repeat(9999)))`, () => { | ||
gunzipSync(compressed); | ||
benchFn(`gunzipSync(@babel/standalone/babel.min.js`, () => { | ||
gunzipSync(compressed, options); | ||
}); | ||
|
||
await run(); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash | ||
. (Join-Path $PSScriptRoot "env.ps1") | ||
|
||
Push-Location (Join-Path $BUN_DEPS_DIR 'libdeflate') | ||
try { | ||
Remove-Item CMakeCache.txt, CMakeFiles, build -Recurse -ErrorAction SilentlyContinue | ||
mkdir -Force build | ||
|
||
Run cmake -S "." -B build @CMAKE_FLAGS -DLIBDEFLATE_BUILD_STATIC_LIB=ON -DLIBDEFLATE_BUILD_SHARED_LIB=OFF -DLIBDEFLATE_BUILD_GZIP=OFF | ||
Run cmake --build build --clean-first --config Release | ||
|
||
# In https://github.com/ebiggers/libdeflate/releases/tag/v1.20, it's outputting libdeflate.a even on Windows | ||
Copy-Item build/deflatestatic.lib $BUN_DEPS_OUT_DIR/deflate.lib | ||
Write-Host "-> deflate.lib" | ||
} finally { Pop-Location } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
set -exo pipefail | ||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh | ||
|
||
mkdir -p $BUN_DEPS_OUT_DIR | ||
cd $BUN_DEPS_DIR/libdeflate | ||
rm -rf build CMakeCache.txt CMakeFiles | ||
cmake "${CMAKE_FLAGS[@]}" -DLIBDEFLATE_BUILD_STATIC_LIB=ON -DLIBDEFLATE_BUILD_SHARED_LIB=OFF -DLIBDEFLATE_BUILD_GZIP=OFF -B build -S . -G Ninja | ||
ninja libdeflate.a -C build | ||
cp build/libdeflate.a $BUN_DEPS_OUT_DIR/libdeflate.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.