update deps and benchemark

This commit is contained in:
Aravinth Manivannan 2021-08-31 14:24:23 +05:30
parent 27502eccbd
commit 6d9a2a4ab1
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
5 changed files with 251 additions and 47 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
/target /target
tarpaulin-report.html tarpaulin-report.html
.env .env
out

174
Cargo.lock generated
View file

@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3
[[package]] [[package]]
name = "ansi_term" name = "ansi_term"
version = "0.11.0" version = "0.11.0"
@ -21,20 +23,25 @@ dependencies = [
] ]
[[package]] [[package]]
name = "bincode" name = "autocfg"
version = "1.3.2" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d175dfa69e619905c4c3cdb7c3c203fa3bdd5d51184e3afdb2742c0280493772" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [ dependencies = [
"byteorder",
"serde", "serde",
] ]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.2.1" version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
@ -45,12 +52,6 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "byteorder"
version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.0"
@ -73,16 +74,19 @@ dependencies = [
] ]
[[package]] [[package]]
name = "cpuid-bool" name = "cpufeatures"
version = "0.1.2" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "darling" name = "darling"
version = "0.12.2" version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06d4a9551359071d1890820e3571252b91229e0712e7c36b08940e603c5a8fc" checksum = "5f2c43f534ea4b0b049015d00269734195e6d3f0f6635cb692251aca6f9f8b3c"
dependencies = [ dependencies = [
"darling_core", "darling_core",
"darling_macro", "darling_macro",
@ -90,9 +94,9 @@ dependencies = [
[[package]] [[package]]
name = "darling_core" name = "darling_core"
version = "0.12.2" version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b443e5fb0ddd56e0c9bfa47dc060c5306ee500cb731f2b91432dd65589a77684" checksum = "8e91455b86830a1c21799d94524df0845183fa55bafd9aa137b01c7d1065fa36"
dependencies = [ dependencies = [
"fnv", "fnv",
"ident_case", "ident_case",
@ -104,9 +108,9 @@ dependencies = [
[[package]] [[package]]
name = "darling_macro" name = "darling_macro"
version = "0.12.2" version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0220073ce504f12a70efc4e7cdaea9e9b1b324872e7ad96a208056d7a638b81" checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a"
dependencies = [ dependencies = [
"darling_core", "darling_core",
"quote", "quote",
@ -115,19 +119,18 @@ dependencies = [
[[package]] [[package]]
name = "derive_builder" name = "derive_builder"
version = "0.10.0" version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ef25735c9f0d0c547d2794701600c94abf030ecb740fad1673fa64461f3573" checksum = "d13202debe11181040ae9063d739fa32cfcaaebe2275fe387703460ae2365b30"
dependencies = [ dependencies = [
"derive_builder_core",
"derive_builder_macro", "derive_builder_macro",
] ]
[[package]] [[package]]
name = "derive_builder_core" name = "derive_builder_core"
version = "0.10.0" version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3150f1e84602847b99d3eeb702487fc364f7d6c94f634e944a68fdbaea09e457" checksum = "66e616858f6187ed828df7c64a6d71720d83767a7f19740b2d1b6fe6327b36e5"
dependencies = [ dependencies = [
"darling", "darling",
"proc-macro2", "proc-macro2",
@ -137,9 +140,9 @@ dependencies = [
[[package]] [[package]]
name = "derive_builder_macro" name = "derive_builder_macro"
version = "0.10.0" version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca1008bddefdc08d1e734aeb27b94f384390af261b4d1a8fb51fe19c577f05c" checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73"
dependencies = [ dependencies = [
"derive_builder_core", "derive_builder_core",
"syn", "syn",
@ -172,9 +175,9 @@ dependencies = [
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.18" version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -187,9 +190,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.92" version = "0.2.101"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714" checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21"
[[package]] [[package]]
name = "mcaptcha-cli" name = "mcaptcha-cli"
@ -199,6 +202,84 @@ dependencies = [
"pow_sha256", "pow_sha256",
] ]
[[package]]
name = "num"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606"
dependencies = [
"num-bigint",
"num-complex",
"num-integer",
"num-iter",
"num-rational",
"num-traits",
]
[[package]]
name = "num-bigint"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76e97c412795abf6c24ba30055a8f20642ea57ca12875220b854cfa501bf1e48"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
"serde",
]
[[package]]
name = "num-complex"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085"
dependencies = [
"num-traits",
"serde",
]
[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
"serde",
]
[[package]]
name = "num-traits"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "opaque-debug" name = "opaque-debug"
version = "0.3.0" version = "0.3.0"
@ -208,19 +289,20 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]] [[package]]
name = "pow_sha256" name = "pow_sha256"
version = "0.2.1" version = "0.2.1"
source = "git+https://github.com/mCaptcha/pow_sha256?tag=0.2.1#df727889c60740bd155d5a06076884636952c66f" source = "git+https://github.com/mCaptcha/pow_sha256#807fa7c75284f6d8d488a6f66a3a1b3301f2f412"
dependencies = [ dependencies = [
"bincode", "bincode",
"derive_builder", "derive_builder",
"num",
"serde", "serde",
"sha2", "sha2",
] ]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.26" version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d"
dependencies = [ dependencies = [
"unicode-xid", "unicode-xid",
] ]
@ -236,18 +318,18 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.125" version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.125" version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -256,13 +338,13 @@ dependencies = [
[[package]] [[package]]
name = "sha2" name = "sha2"
version = "0.9.3" version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" checksum = "9204c41a1597a8c5af23c82d1c921cb01ec0a4c59e07a9c7306062829a3903f3"
dependencies = [ dependencies = [
"block-buffer", "block-buffer",
"cfg-if", "cfg-if",
"cpuid-bool", "cpufeatures",
"digest", "digest",
"opaque-debug", "opaque-debug",
] ]
@ -281,9 +363,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.68" version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87" checksum = "b7f58f7e8eaa0009c5fec437aabf511bd9933e4b2d7407bd05273c01a8906ea7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -313,9 +395,9 @@ checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.2.1" version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]] [[package]]
name = "vec_map" name = "vec_map"

View file

@ -6,5 +6,5 @@ license = "AGPL-3.0"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
pow_sha256 = { version = "0.2.1", git = "https://github.com/mCaptcha/pow_sha256", tag="0.2.1"} pow_sha256 = { version = "0.2.1", git = "https://github.com/mCaptcha/pow_sha256" }
clap = "2.33" clap = "2.33"

100
benches/2021-08-31 Normal file
View file

@ -0,0 +1,100 @@
factor = 50000
[*] factor: 1 difficulty: 50000
real 0m0.040s
user 0m0.040s
sys 0m0.000s
[*] factor: 6 difficulty: 300000
real 0m0.122s
user 0m0.122s
sys 0m0.000s
[*] factor: 11 difficulty: 550000
real 0m0.124s
user 0m0.119s
sys 0m0.003s
[*] factor: 16 difficulty: 800000
real 0m0.123s
user 0m0.118s
sys 0m0.003s
[*] factor: 21 difficulty: 1050000
real 0m0.933s
user 0m0.932s
sys 0m0.000s
[*] factor: 26 difficulty: 1300000
user 0m1.227s
sys 0m0.007s
[*] factor: 31 difficulty: 1550000
real 0m1.260s
user 0m1.256s
sys 0m0.003s
[*] factor: 36 difficulty: 1800000
real 0m1.243s
user 0m1.242s
sys 0m0.000s
[*] factor: 41 difficulty: 2050000
real 0m2.524s
user 0m2.510s
sys 0m0.000s
[*] factor: 46 difficulty: 2300000
real 0m2.545s
user 0m2.543s
sys 0m0.000s
[*] factor: 51 difficulty: 2550000
real 0m2.561s
user 0m2.551s
sys 0m0.004s
[*] factor: 56 difficulty: 2800000
real 0m2.555s
user 0m2.540s
sys 0m0.006s
[*] factor: 61 difficulty: 3050000
real 0m2.513s
user 0m2.508s
sys 0m0.000s
[*] factor: 66 difficulty: 3300000
real 0m2.484s
user 0m2.481s
sys 0m0.000s
[*] factor: 71 difficulty: 3550000
real 0m2.643s
user 0m2.642s
sys 0m0.000s
[*] factor: 76 difficulty: 3800000
real 0m2.663s
user 0m2.661s
sys 0m0.000s
[*] factor: 81 difficulty: 4050000
real 0m2.663s
user 0m2.660s
sys 0m0.000s
[*] factor: 86 difficulty: 4300000
real 0m2.689s
user 0m2.683s
sys 0m0.004s
[*] factor: 91 difficulty: 4550000
real 0m2.688s
user 0m2.686s
sys 0m0.000s
[*] factor: 96 difficulty: 4800000
real 0m2.517s
user 0m2.509s
sys 0m0.003s

21
scripts/bench.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/bash
set -euo pipefail
readonly OUT_FILE=out
readonly PHRASE="c353d3b790d0342e475b349605d770ca68fed0f0d022eefba3a9ab29ffbf"
readonly SALT="1661dd8198c5c28803cdc2e207e49ad64dbb8a99221276a8d3d910b42ecd"
readonly FACTOR=50000
rm $OUT_FILE || true
for f in $(seq 1 5 100)
do
d=$(calc $FACTOR \* $f) #$(calc 10 ^ $f))
echo "[*] factor: $f difficulty: $d"
echo "[*] factor: $f difficulty: $d" >> $OUT_FILE
{ time ./target/release/mcaptcha-cli -d $d -p $PHRASE -s $SALT > /dev/null; } 2>> $OUT_FILE
echo >> $OUT_FILE
echo >> $OUT_FILE
done