move to ffi-napi

master
Avril 4 years ago
parent 094b6c06f7
commit 5a9a8d97d6
Signed by: flanchan
GPG Key ID: 966FE03CC0E0B199

@ -1,6 +1,6 @@
INSTALL:= /usr/local/lib INSTALL:= /usr/lib64
INSTALL-BIN:= /usr/local/bin INSTALL-BIN:= /usr/bin
INSTALL-INCLUDE:=/usr/local/include INSTALL-INCLUDE:=/usr/include
CLI:= cli CLI:= cli

@ -3,7 +3,7 @@ INCLUDE:=include/
LIB:=lib LIB:=lib
BUILD:=build BUILD:=build
CFLAGS:= -g -Wall -pedantic CFLAGS:= -g -Wall -pedantic
LFLAGS:= -L$(LIB) -lkhash LFLAGS:= -lkhash
all: clean test kana-hash all: clean test kana-hash

@ -1,6 +1,6 @@
const ffi = require('ffi'); const ffi = require('ffi-napi');
const struct = require('ref-struct'); const struct = require('ref-struct-napi');
const ref = require('ref'); const ref = require('ref-napi');
const Salt = struct({ const Salt = struct({
'type': 'char', 'type': 'char',

@ -1,76 +1,134 @@
{ {
"name": "kana-hash", "name": "kana-hash",
"version": "1.0.0", "version": "1.2.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"bindings": { "debug": {
"version": "1.5.0", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": { "requires": {
"file-uri-to-path": "1.0.0" "ms": "^2.1.1"
} }
}, },
"debug": { "ffi-napi": {
"version": "2.6.9", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "resolved": "https://registry.npmjs.org/ffi-napi/-/ffi-napi-3.0.1.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "integrity": "sha512-zOvTqC9pjXNfVUruk4phi+Itayg3yefgiR/CZtr09OcrYulBq9jeUtf/GvFeXfNRv8q2qu3+ijMPj4rewTWbVg==",
"requires": { "requires": {
"ms": "2.0.0" "debug": "^4.1.1",
"get-uv-event-loop-napi-h": "^1.0.5",
"node-addon-api": "^2.0.0",
"node-gyp-build": "^4.2.1",
"ref-napi": "^2.0.1",
"ref-struct-di": "^1.1.0"
} }
}, },
"ffi": { "get-symbol-from-current-process-h": {
"version": "2.3.0", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/ffi/-/ffi-2.3.0.tgz", "resolved": "https://registry.npmjs.org/get-symbol-from-current-process-h/-/get-symbol-from-current-process-h-1.0.2.tgz",
"integrity": "sha512-vkPA9Hf9CVuQ5HeMZykYvrZF2QNJ/iKGLkyDkisBnoOOFeFXZQhUPxBARPBIZMJVulvBI2R+jgofW03gyPpJcQ==", "integrity": "sha512-syloC6fsCt62ELLrr1VKBM1ggOpMdetX9hTrdW77UQdcApPHLmf7CI7OKcN1c9kYuNxKcDe4iJ4FY9sX3aw2xw=="
},
"get-uv-event-loop-napi-h": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/get-uv-event-loop-napi-h/-/get-uv-event-loop-napi-h-1.0.6.tgz",
"integrity": "sha512-t5c9VNR84nRoF+eLiz6wFrEp1SE2Acg0wS+Ysa2zF0eROes+LzOfuTaVHxGy8AbS8rq7FHEJzjnCZo1BupwdJg==",
"requires": { "requires": {
"bindings": "~1.2.0", "get-symbol-from-current-process-h": "^1.0.1"
"debug": "2", }
"nan": "2", },
"ref": "1", "ms": {
"ref-struct": "1" "version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node-addon-api": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz",
"integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA=="
},
"node-gyp-build": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.2.tgz",
"integrity": "sha512-Lqh7mrByWCM8Cf9UPqpeoVBBo5Ugx+RKu885GAzmLBVYjeywScxHXPGLa4JfYNZmcNGwzR0Glu5/9GaQZMFqyA=="
},
"ref-napi": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-2.0.3.tgz",
"integrity": "sha512-zsAhPhh9gUlk0pP5iR9nhvwFeC/E9G1X0cdH/qQRTwx3VDgVi40Aflq/EdbobcVg++RNaMxZsbaQV+/E2u57LQ==",
"requires": {
"debug": "^4.1.1",
"get-symbol-from-current-process-h": "^1.0.2",
"node-addon-api": "^2.0.0",
"node-gyp-build": "^4.2.1"
}
},
"ref-struct-di": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ref-struct-di/-/ref-struct-di-1.1.1.tgz",
"integrity": "sha512-2Xyn/0Qgz89VT+++WP0sTosdm9oeowLP23wRJYhG4BFdMUrLj3jhwHZNEytYNYgtPKLNTP3KJX4HEgBvM1/Y2g==",
"requires": {
"debug": "^3.1.0"
}, },
"dependencies": { "dependencies": {
"bindings": { "debug": {
"version": "1.2.1", "version": "3.2.6",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
"integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=" "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
"requires": {
"ms": "^2.1.1"
}
} }
} }
}, },
"file-uri-to-path": { "ref-struct-napi": {
"version": "1.0.0", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", "resolved": "https://registry.npmjs.org/ref-struct-napi/-/ref-struct-napi-1.1.1.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" "integrity": "sha512-YgS5/d7+kT5zgtySYI5ieH0hREdv+DabgDvoczxsui0f9VLm0rrDcWEj4DHKehsH+tJnVMsLwuyctWgvdEcVRw==",
"requires": {
"debug": "2",
"ref-napi": "^1.4.2"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
}, },
"ms": { "ms": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}, },
"nan": { "ref-napi": {
"version": "2.14.1", "version": "1.5.2",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-1.5.2.tgz",
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" "integrity": "sha512-hwyNmWpUkt1bDWDW4aiwCoC+SJfJO69UIdjqssNqdaS0sYJpgqzosGg/rLtk69UoQ8drZdI9yyQefM7eEMM3Gw==",
"requires": {
"debug": "^3.1.0",
"node-addon-api": "^2.0.0",
"node-gyp-build": "^4.2.1"
}, },
"ref": { "dependencies": {
"version": "1.3.5", "debug": {
"resolved": "https://registry.npmjs.org/ref/-/ref-1.3.5.tgz", "version": "3.2.6",
"integrity": "sha512-2cBCniTtxcGUjDpvFfVpw323a83/0RLSGJJY5l5lcomZWhYpU2cuLdsvYqMixvsdLJ9+sTdzEkju8J8ZHDM2nA==", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
"requires": { "requires": {
"bindings": "1", "ms": "^2.1.1"
"debug": "2",
"nan": "2"
} }
}, },
"ref-struct": { "ms": {
"version": "1.1.0", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/ref-struct/-/ref-struct-1.1.0.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha1-XV7mWtQc78Olxf60BYcmHkee3BM=", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
"requires": { }
"debug": "2", }
"ref": "1" }
} }
} }
} }

@ -9,7 +9,7 @@
"author": "", "author": "",
"license": "GPL", "license": "GPL",
"dependencies": { "dependencies": {
"ffi": "^2.3.0", "ffi-napi": "^3.0.1",
"ref-struct": "^1.1.0" "ref-struct-napi": "^1.1.1"
} }
} }

@ -1,4 +1,4 @@
const ref = require('ref'); const ref = require('ref-napi');
/// Create a new salt from the string `buffer`. /// Create a new salt from the string `buffer`.
function Salt(buffer, tag) function Salt(buffer, tag)

@ -1,5 +1,4 @@
//#![feature(const_generics)] //#![feature(const_generics)]
#![feature(test)]
#![allow(dead_code)] #![allow(dead_code)]
use std::{ use std::{
io::{ io::{
@ -8,8 +7,6 @@ use std::{
fmt::Write, fmt::Write,
}; };
extern crate test;
type HASHER = hash::Crc64Checksum; type HASHER = hash::Crc64Checksum;
#[cfg(test)] #[cfg(test)]
@ -17,64 +14,6 @@ mod tests {
use super::*; use super::*;
use std::collections::HashMap; use std::collections::HashMap;
use test::{Bencher, black_box,}; use test::{Bencher, black_box,};
#[bench]
fn speed_sha256t(b: &mut Bencher)
{
const ITERATIONS: usize = 1;
let context = ctx::Context::new(ctx::Algorithm::Sha256Truncated, salt::Salt::random().unwrap());
const INPUT: &'static [u8] = b"owo uwu owo uwuw owuw ua eaowi oiho aido iahs doi ajosidj aoi";
b.iter(|| {
for _x in 0..ITERATIONS
{
black_box(generate(&context, INPUT)).unwrap();
}
});
}
#[bench]
fn speed_sha256(b: &mut Bencher)
{
const ITERATIONS: usize = 1;
let context = ctx::Context::new(ctx::Algorithm::Sha256, salt::Salt::random().unwrap());
const INPUT: &'static [u8] = b"owo uwu owo uwuw owuw ua eaowi oiho aido iahs doi ajosidj aoi";
b.iter(|| {
for _x in 0..ITERATIONS
{
black_box(generate(&context, INPUT)).unwrap();
}
});
}
#[bench]
fn speed_crc64(b: &mut Bencher)
{
const ITERATIONS: usize = 1;
let context = ctx::Context::new(ctx::Algorithm::Crc64, salt::Salt::random().unwrap());
const INPUT: &'static [u8] = b"owo uwu owo uwuw owuw ua eaowi oiho aido iahs doi ajosidj aoi";
b.iter(|| {
for _x in 0..ITERATIONS
{
black_box(generate(&context, INPUT)).unwrap();
}
});
}
#[bench]
fn speed_crc32(b: &mut Bencher)
{
const ITERATIONS: usize = 1;
let context = ctx::Context::new(ctx::Algorithm::Crc32, salt::Salt::random().unwrap());
const INPUT: &'static [u8] = b"owo uwu owo uwuw owuw ua eaowi oiho aido iahs doi ajosidj aoi";
b.iter(|| {
for _x in 0..ITERATIONS
{
black_box(generate(&context, INPUT)).unwrap();
}
});
}
#[test] #[test]
fn distrubution() fn distrubution()
{ {

Loading…
Cancel
Save