Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #[no_std] and WebAssembly support #21

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Add #[no_std] and WebAssembly support #21

wants to merge 17 commits into from

Conversation

rubdos
Copy link
Member

@rubdos rubdos commented Jul 23, 2024

Goal is mainly to showcase wasm support.

@rubdos rubdos marked this pull request as ready for review July 23, 2024 14:35
@rubdos
Copy link
Member Author

rubdos commented Jul 23, 2024

Javascript stolen adapted from https://github.com/fpapado/blurhash-rust-wasm

import * as blurhash from "blurhash";

// You can use this to construct canvas-compatible resources
try {
  const pixels = blurhash.decode("LKO2?U%2Tw=w]~RBVZRi};RPxuwH", 40, 30);
  console.log(pixels);
} catch (error) {
  console.log(error);
}
❯ npm run  main

> [email protected] main
> node index.js

Uint8Array(4800) [
  1, 1, 1, 255, 1, 1, 1, 255, 1, 1, 1, 255,
  1, 1, 1, 255, 1, 1, 1, 255, 1, 1, 1, 255,
  1, 1, 1, 255, 1, 1, 1, 255, 1, 1, 1, 255,
  1, 1, 1, 255, 1, 1, 1, 255, 1, 1, 1, 255,
  1, 1, 1, 255, 1, 1, 1, 255, 1, 1, 1, 255,
  1, 1, 1, 255, 1, 1, 1, 255, 1, 1, 1, 255,
  1, 1, 1, 255, 1, 1, 1, 255, 1, 1, 1, 255,
  1, 1, 1, 255, 1, 1, 1, 255, 1, 1, 1, 255,
  1, 1, 1, 255,
  ... 4700 more items
]

@rubdos
Copy link
Member Author

rubdos commented Jul 24, 2024

blurhash-rs x 6,035 ops/sec ±0.35% (96 runs sampled)
blurhash-rust-wasm x 3,191 ops/sec ±0.70% (95 runs sampled)

meh, ENOTFASTENOUGH :'-)

@rubdos
Copy link
Member Author

rubdos commented Jul 24, 2024

> [email protected] main
> node index.js

Uint8Array(4800) [
  252, 194, 161, 255, 252, 194, 161, 255, 251, 193, 162, 255,
  249, 193, 163, 255, 247, 192, 163, 255, 245, 192, 164, 255,
  243, 191, 165, 255, 240, 190, 166, 255, 238, 189, 167, 255,
  235, 188, 168, 255, 233, 187, 168, 255, 231, 186, 168, 255,
  230, 186, 168, 255, 229, 185, 167, 255, 229, 184, 166, 255,
  230, 184, 165, 255, 231, 184, 163, 255, 232, 184, 161, 255,
  234, 184, 158, 255, 237, 185, 156, 255, 239, 185, 154, 255,
  241, 186, 152, 255, 244, 187, 150, 255, 246, 188, 148, 255,
  247, 189, 147, 255,
  ... 4700 more items
]
Uint8Array(4800) [
  251, 193, 161, 255, 251, 193, 161, 255, 250, 193, 161, 255,
  249, 192, 162, 255, 247, 192, 163, 255, 245, 191, 164, 255,
  242, 190, 165, 255, 240, 190, 166, 255, 237, 189, 167, 255,
  235, 188, 167, 255, 232, 187, 168, 255, 231, 186, 168, 255,
  229, 185, 167, 255, 229, 184, 167, 255, 229, 184, 166, 255,
  229, 184, 164, 255, 230, 184, 162, 255, 232, 184, 160, 255,
  234, 184, 158, 255, 236, 184, 156, 255, 239, 185, 153, 255,
  241, 186, 151, 255, 243, 187, 149, 255, 245, 188, 148, 255,
  247, 189, 147, 255,
  ... 4700 more items
]
blurhash-rs decode x 27,498 ops/sec ±0.98% (86 runs sampled)
blurhash-rust-wasm decode x 3,262 ops/sec ±0.40% (95 runs sampled)
Fastest is blurhash-rs decode

🤷

rubdos added 3 commits July 24, 2024 10:59
When the test harness is built in lib mode, it seems that the `std`
feature flag is disabled, but the f32::* methods are actually available.
@rubdos rubdos changed the title Add #[no_std] support Add #[no_std] and WebAssembly support Jul 24, 2024
@rubdos
Copy link
Member Author

rubdos commented Jul 24, 2024

[2024-07-24T11:05:13.746Z] ['error'] There was an error running the uploader: Error uploading to https://codecov.io: Error: There was an error fetching the storage URL during POST: 429 - {'detail': ErrorDetail(string='Rate limit reached. Please upload with the Codecov repository upload token to resolve issue. Expected time to availability: 3347s.', code='throttled')}

Ugh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant