Compare commits

..

3 Commits

Author SHA1 Message Date
0b21d119af Bench.
All checks were successful
isspam build / build (push) Successful in 2m30s
2024-12-01 22:03:07 +01:00
00d8bdf3ce Performance upgrade C version. 2024-12-01 22:02:32 +01:00
6be2d372f2 A few optimizations. 2024-12-01 19:40:01 +01:00
81 changed files with 381 additions and 186 deletions

4
.gitignore vendored
View File

@ -2,7 +2,3 @@
.vscode .vscode
publish publish
books books
totals.txt
totals
output
output.txt

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":7959095874983568062,"features":"[\"default\", \"std\"]","declared_features":"[\"default\", \"std\"]","target":15878351248853952023,"profile":18277820415669657429,"path":11272947995469734555,"deps":[[13029015263761501439,"crossbeam_utils",false,911544744987415537],[17638357056475407756,"crossbeam_epoch",false,5520351269545404989]],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/crossbeam-deque-f2c73cf999f703ff/dep-lib-crossbeam_deque","checksum":false}}],"rustflags":[],"metadata":14304628380895324452,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":7959095874983568062,"features":"[\"alloc\", \"std\"]","declared_features":"[\"alloc\", \"default\", \"loom\", \"loom-crate\", \"nightly\", \"std\"]","target":3011025219128477647,"profile":18277820415669657429,"path":2144046578742159444,"deps":[[13029015263761501439,"crossbeam_utils",false,911544744987415537]],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/crossbeam-epoch-ef8048f2af92097a/dep-lib-crossbeam_epoch","checksum":false}}],"rustflags":[],"metadata":8562320424510714295,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
{"rustc":7959095874983568062,"features":"[\"default\", \"std\"]","declared_features":"[\"default\", \"loom\", \"nightly\", \"std\"]","target":9652763411108993936,"profile":4838097492018903191,"path":4917352724713626466,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/crossbeam-utils-22798c5284de80b4/dep-build-script-build-script-build","checksum":false}}],"rustflags":[],"metadata":1609393243086812936,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":7959095874983568062,"features":"","declared_features":"","target":0,"profile":0,"path":0,"deps":[[13029015263761501439,"build_script_build",false,8212287427884875785]],"local":[{"RerunIfChanged":{"output":"release/build/crossbeam-utils-35fd8531433c59c2/output","paths":["no_atomic.rs"]}}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":7959095874983568062,"features":"[\"default\", \"std\"]","declared_features":"[\"default\", \"loom\", \"nightly\", \"std\"]","target":17763872635700314276,"profile":321733331732146078,"path":271604838124260648,"deps":[[13029015263761501439,"build_script_build",false,11902837482427142058]],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/crossbeam-utils-e5ce1a8819e49c8e/dep-lib-crossbeam_utils","checksum":false}}],"rustflags":[],"metadata":1609393243086812936,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":7959095874983568062,"features":"[]","declared_features":"[\"default\", \"serde\", \"use_std\"]","target":10829531579163655734,"profile":18277820415669657429,"path":1883079978833514601,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/either-1676d0294145a00e/dep-lib-either","checksum":false}}],"rustflags":[],"metadata":14516623572814205243,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
6cdab6e00cdb4d7c

View File

@ -0,0 +1 @@
{"rustc":7959095874983568062,"features":"[]","declared_features":"[\"web_spin_lock\"]","target":15340428944421145304,"profile":18277820415669657429,"path":7990184197366143812,"deps":[[7459069637002492900,"either",false,1414994393305782802],[10618402922884942723,"rayon_core",false,839421907456724241]],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/rayon-90d8c1cd90afcdd6/dep-lib-rayon","checksum":false}}],"rustflags":[],"metadata":16007375514346065096,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":7959095874983568062,"features":"[]","declared_features":"[\"web_spin_lock\"]","target":759009288358699041,"profile":18277820415669657429,"path":8102980474510446164,"deps":[[10618402922884942723,"build_script_build",false,1990939350532090195],[13029015263761501439,"crossbeam_utils",false,911544744987415537],[17516414546981198098,"crossbeam_deque",false,17207161826504668286]],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/rayon-core-702848a32db861bb/dep-lib-rayon_core","checksum":false}}],"rustflags":[],"metadata":14590378261418540923,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
{"rustc":7959095874983568062,"features":"","declared_features":"","target":0,"profile":0,"path":0,"deps":[[10618402922884942723,"build_script_build",false,5840249596962437066]],"local":[{"RerunIfChanged":{"output":"release/build/rayon-core-9285c8c105391613/output","paths":["build.rs"]}}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0}

View File

@ -0,0 +1 @@
{"rustc":7959095874983568062,"features":"[]","declared_features":"[\"web_spin_lock\"]","target":9652763411108993936,"profile":385020235239010606,"path":6127636580977020660,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/rayon-core-dd10fa83944f86f3/dep-build-script-build-script-build","checksum":false}}],"rustflags":[],"metadata":14590378261418540923,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":7959095874983568062,"features":"[]","declared_features":"[]","target":10519780086885261595,"profile":18277820415669657429,"path":10602529704205407992,"deps":[[17775862536196513609,"rayon",false,8957056082265954924]],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/risspam-8a60801288c04c13/dep-bin-risspam","checksum":false}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1,9 @@
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/build/crossbeam-utils-22798c5284de80b4/build_script_build-22798c5284de80b4: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/build.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/no_atomic.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/build-common.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/build/crossbeam-utils-22798c5284de80b4/build_script_build-22798c5284de80b4.d: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/build.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/no_atomic.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/build-common.rs
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/build.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/no_atomic.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/build-common.rs:
# env-dep:CARGO_PKG_NAME=crossbeam-utils

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1,2 @@
cargo:rerun-if-changed=no_atomic.rs
cargo:rustc-check-cfg=cfg(crossbeam_no_atomic,crossbeam_sanitize_thread)

View File

@ -0,0 +1 @@
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/build/crossbeam-utils-35fd8531433c59c2/out

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
cargo:rerun-if-changed=build.rs

View File

@ -0,0 +1 @@
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/build/rayon-core-9285c8c105391613/out

View File

@ -0,0 +1,5 @@
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/build/rayon-core-dd10fa83944f86f3/build_script_build-dd10fa83944f86f3: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/build.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/build/rayon-core-dd10fa83944f86f3/build_script_build-dd10fa83944f86f3.d: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/build.rs
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/build.rs:

View File

@ -0,0 +1,8 @@
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/libcrossbeam_deque-f2c73cf999f703ff.rmeta: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-deque-0.8.5/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-deque-0.8.5/src/deque.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/libcrossbeam_deque-f2c73cf999f703ff.rlib: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-deque-0.8.5/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-deque-0.8.5/src/deque.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/crossbeam_deque-f2c73cf999f703ff.d: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-deque-0.8.5/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-deque-0.8.5/src/deque.rs
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-deque-0.8.5/src/lib.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-deque-0.8.5/src/deque.rs:

View File

@ -0,0 +1,18 @@
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/libcrossbeam_epoch-ef8048f2af92097a.rmeta: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/atomic.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/collector.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/deferred.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/epoch.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/guard.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/internal.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/list.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/once_lock.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/queue.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/default.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/libcrossbeam_epoch-ef8048f2af92097a.rlib: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/atomic.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/collector.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/deferred.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/epoch.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/guard.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/internal.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/list.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/once_lock.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/queue.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/default.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/crossbeam_epoch-ef8048f2af92097a.d: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/atomic.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/collector.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/deferred.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/epoch.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/guard.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/internal.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/list.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/once_lock.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/queue.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/default.rs
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/lib.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/atomic.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/collector.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/deferred.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/epoch.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/guard.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/internal.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/mod.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/list.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/once_lock.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/sync/queue.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-epoch-0.9.18/src/default.rs:

View File

@ -0,0 +1,19 @@
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/libcrossbeam_utils-e5ce1a8819e49c8e.rmeta: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/seq_lock.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/atomic_cell.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/consume.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/cache_padded.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/backoff.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/once_lock.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/parker.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/sharded_lock.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/wait_group.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/thread.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/libcrossbeam_utils-e5ce1a8819e49c8e.rlib: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/seq_lock.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/atomic_cell.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/consume.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/cache_padded.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/backoff.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/once_lock.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/parker.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/sharded_lock.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/wait_group.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/thread.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/crossbeam_utils-e5ce1a8819e49c8e.d: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/seq_lock.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/atomic_cell.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/consume.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/cache_padded.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/backoff.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/once_lock.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/parker.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/sharded_lock.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/wait_group.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/thread.rs
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/lib.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/mod.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/seq_lock.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/atomic_cell.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/atomic/consume.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/cache_padded.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/backoff.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/mod.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/once_lock.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/parker.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/sharded_lock.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/sync/wait_group.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.20/src/thread.rs:

View File

@ -0,0 +1,9 @@
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/libeither-1676d0294145a00e.rmeta: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/either-1.13.0/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/either-1.13.0/src/iterator.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/either-1.13.0/src/into_either.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/libeither-1676d0294145a00e.rlib: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/either-1.13.0/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/either-1.13.0/src/iterator.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/either-1.13.0/src/into_either.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/either-1676d0294145a00e.d: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/either-1.13.0/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/either-1.13.0/src/iterator.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/either-1.13.0/src/into_either.rs
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/either-1.13.0/src/lib.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/either-1.13.0/src/iterator.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/either-1.13.0/src/into_either.rs:

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,29 @@
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/librayon_core-702848a32db861bb.rmeta: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/private.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/broadcast/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/broadcast/test.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/job.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/latch.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/registry.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/scope/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/sleep/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/sleep/counters.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/spawn/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/thread_pool/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/thread_pool/test.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/unwind.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/quicksort_race1.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/quicksort_race2.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/quicksort_race3.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/rc_return.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/rc_upvar.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/scope_join_bad.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/test.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/librayon_core-702848a32db861bb.rlib: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/private.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/broadcast/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/broadcast/test.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/job.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/latch.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/registry.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/scope/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/sleep/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/sleep/counters.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/spawn/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/thread_pool/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/thread_pool/test.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/unwind.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/quicksort_race1.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/quicksort_race2.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/quicksort_race3.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/rc_return.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/rc_upvar.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/scope_join_bad.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/test.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/rayon_core-702848a32db861bb.d: /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/lib.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/private.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/broadcast/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/broadcast/test.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/job.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/latch.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/registry.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/scope/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/sleep/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/sleep/counters.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/spawn/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/thread_pool/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/thread_pool/test.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/unwind.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/mod.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/quicksort_race1.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/quicksort_race2.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/quicksort_race3.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/rc_return.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/rc_upvar.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/scope_join_bad.rs /home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/test.rs
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/lib.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/private.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/broadcast/mod.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/broadcast/test.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/job.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/latch.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/registry.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/scope/mod.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/sleep/mod.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/sleep/counters.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/spawn/mod.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/thread_pool/mod.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/thread_pool/test.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/unwind.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/mod.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/quicksort_race1.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/quicksort_race2.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/quicksort_race3.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/rc_return.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/rc_upvar.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/compile_fail/scope_join_bad.rs:
/home/retoor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/test.rs:

View File

@ -0,0 +1,5 @@
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/risspam-8a60801288c04c13: src/main.rs
/home/retoor/projects/spam/12bitfloat_rust/risspam/target/release/deps/risspam-8a60801288c04c13.d: src/main.rs
src/main.rs:

View File

@ -1,7 +1,7 @@
CC = gcc CC = gcc
CFLAGS = -Wall -Werror -Wextra -Ofast -std=c2x CFLAGS = -Wall -Werror -Wextra -Ofast -std=c2x
all: build run valgrind build_risspam run_risspam all: build run valgrind build_risspam run_risspam benchmark
build: build:
@echo "Compiling retoor_c project.". @echo "Compiling retoor_c project.".
@ -39,3 +39,10 @@ run_not_spam_risspam:
valgrind: build valgrind: build
valgrind ./isspam ./spam/*.txt valgrind ./isspam ./spam/*.txt
benchmark:
-@rm -rf books
echo "Extracting books."
tar -xzf books.tar.gz books/
echo "Extracted books."
python bench.py

11
bench.py Normal file
View File

@ -0,0 +1,11 @@
import subprocess
import time
print("***benchmarking***")
time_start = time.time()
subprocess.check_output('./isspam books/*.txt', shell=True)
print("Time C:",time.time() - time_start)
time_start = time.time()
subprocess.check_output('./risspam books/*.txt', shell=True)
print("Time Rust:",time.time() - time_start)
print("***end benchmark***")

BIN
isspam

Binary file not shown.

View File

@ -4,8 +4,8 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "rstring_list.h"
#include "rstr.h" #include "rstr.h"
#include "rstring_list.h"
#include <ctype.h> #include <ctype.h>
#define sl rstring_list_t #define sl rstring_list_t
@ -25,24 +25,16 @@ char *forbidden_words[] = {
"transaction", "essential", "managing", "contact", "contacting", "understanding", "assets", "funds", NULL}; "transaction", "essential", "managing", "contact", "contacting", "understanding", "assets", "funds", NULL};
bool show_capitalized = false; bool stricmp(char *word1, char *word2) {
bool show_sentences = false; while (*word1 && tolower(*word1) == tolower(*word2)) {
bool show_words = false; word1++;
bool show_numbers = false; word2++;
bool show_forbidden_words = true;
bool file_exists(char * path){
FILE * f = fopen(path, "r");
bool result = f != NULL;
if(f){
fclose(f);
} }
return result; return *word1 == *word2;
} }
void sld(sl *lst) { void sld(sl *lst) {
for (ulonglong i = 0; i < lst->count; i++) { for (ulonglong i = 0; i < lst->count; i++) {
printf("<%llu:%s>\n", i, lst->strings[i]); printf("<%llu:%s>\n", i, lst->strings[i]);
@ -65,6 +57,7 @@ char *remove_preserved_chars(char *content) {
} }
return cc; return cc;
} }
//Memory usage: 29 TB, 213.322.618 (re)allocated, 106.670.251 unqiue free'd, 0 in use.
char *slds(sl *lst) { char *slds(sl *lst) {
str_t *buffer = strn(1337); str_t *buffer = strn(1337);
@ -81,20 +74,6 @@ char *slds(sl *lst) {
bool isws(char c) { return c == '\t' || c == '\n' || c == ' ' || c == ','; } bool isws(char c) { return c == '\t' || c == '\n' || c == ' ' || c == ','; }
char *stripws(char *content) {
char *cc = (char *)malloc(strlen(content) + 1);
*cc = 0;
char *ccp = cc;
while (*content) {
if (!isws(*content)) {
*ccp = *content;
ccp++;
*ccp = 0;
}
content++;
}
return cc;
}
char *fread_till_eof(FILE *f) { char *fread_till_eof(FILE *f) {
char c; char c;
@ -106,12 +85,10 @@ char *fread_till_eof(FILE *f) {
return content; return content;
} }
rstring_list_t *get_sentences(char *content) { int get_sentences(char *content) {
int count = 0;
rstring_list_t *sentences = rstring_list_new();
char *sentence_buffer = (char *)malloc(strlen(content) + 1); char *sentence_buffer = (char *)malloc(strlen(content) + 1);
char *sentence_buffer_p = sentence_buffer; char *sentence_buffer_p = sentence_buffer;
// rbuffer_t * buffer = rbuffer_new(NULL,0);
bool in_line = false; bool in_line = false;
while (*content) { while (*content) {
if ((*content == ' ' || *content == '\t' || *content == '\n') && !in_line) { if ((*content == ' ' || *content == '\t' || *content == '\n') && !in_line) {
@ -124,7 +101,7 @@ rstring_list_t *get_sentences(char *content) {
*sentence_buffer_p = *content; *sentence_buffer_p = *content;
sentence_buffer_p++; sentence_buffer_p++;
*sentence_buffer_p = 0; *sentence_buffer_p = 0;
rstring_list_add(sentences, sentence_buffer); count++;
sentence_buffer_p = sentence_buffer; sentence_buffer_p = sentence_buffer;
*sentence_buffer = 0; *sentence_buffer = 0;
content++; content++;
@ -137,32 +114,55 @@ rstring_list_t *get_sentences(char *content) {
content++; content++;
} }
free(sentence_buffer); free(sentence_buffer);
return sentences; return count;
} }
rstring_list_t *get_words(char *content) {
rstring_list_t *words = rstring_list_new(); bool is_forbidden_word(char *word) {
for (int j = 0; forbidden_words[j] != NULL; j++) {
if (stricmp(word, forbidden_words[j])) {
return true;
}
}
return false;
}
int get_words(char *content, int * count_caps, int *fw_count) {
int count = 0;
char *word_buffer = (char *)malloc(strlen(content) + 1); char *word_buffer = (char *)malloc(strlen(content) + 1);
char *word_buffer_p = word_buffer; char *word_buffer_p = word_buffer;
*word_buffer_p = 0; *word_buffer_p = 0;
bool has_lcase = false;
// rbuffer_t * buffer = rbuffer_new(NULL,0); // rbuffer_t * buffer = rbuffer_new(NULL,0);
while (*content) { while (*content) {
if (*content == ' ' || *content == '\t' || *content == '\n') { if (*content == ' ' || *content == '\t' || *content == '\n') {
if (word_buffer_p != word_buffer) { if (word_buffer_p != word_buffer) {
rstring_list_add(words, word_buffer); if(!has_lcase)
{
(*count_caps)++;
}
count++;
if(is_forbidden_word(word_buffer)){
(*fw_count)++;
}
word_buffer_p = word_buffer; word_buffer_p = word_buffer;
*word_buffer = 0; *word_buffer = 0;
} }
has_lcase = false;
content++; content++;
continue; continue;
} }
*word_buffer_p = *content; *word_buffer_p = *content;
if(islower(*content) == *content)
has_lcase = true;
word_buffer_p++; word_buffer_p++;
*word_buffer_p = 0; *word_buffer_p = 0;
content++; content++;
} }
free(word_buffer); free(word_buffer);
return words; return count;
} }
bool is_fully_capitalized_word(char *word) { bool is_fully_capitalized_word(char *word) {
@ -174,31 +174,24 @@ bool is_fully_capitalized_word(char *word) {
return true; return true;
} }
sl *get_capitalized_words(char *content) { int get_capitalized_words(sl *all_words) {
sl *capitalized_words = sln(); int count = 0;
sl *sentences = get_sentences(content);
for (uint j = 0; j < sentences->count; j++) {
char *sentence = sentences->strings[j];
sl *all_words = get_words(sentence);
// Always skip the first word since sentences start with
for (uint i = 0; i < all_words->count; i++) { for (uint i = 0; i < all_words->count; i++) {
if (is_fully_capitalized_word(all_words->strings[i])) { if (is_fully_capitalized_word(all_words->strings[i])) {
rstring_list_add(capitalized_words, all_words->strings[i]); count++;
} }
} }
slf(all_words);
} return count;
slf(sentences);
return capitalized_words;
} }
char *clean_content(char *content) { char *clean_content(char *content) {
char *allowed_ichars = "01234567891abcdefghijklmnopqrstuvwxyz \n.,!?"; char *allowed_ichars = "01234567891abcdefghijklmnopqrstuvwxyz.,!?";
char *clean_content = (char *)malloc(strlen(content) + 1); char *clean_content = (char *)malloc(strlen(content) + 1);
char *clean_content_p = clean_content; char *clean_content_p = clean_content;
*clean_content_p = 0; *clean_content_p = 0;
while (*content) { while (*content) {
if (strchr(allowed_ichars, tolower(*content))) { if (strchr(allowed_ichars, tolower(*content))) {
*clean_content_p = *content; *clean_content_p = *content;
clean_content_p++; clean_content_p++;
@ -209,177 +202,123 @@ char *clean_content(char *content) {
return clean_content; return clean_content;
} }
sl *get_numbers(char *content) { int get_numbers(char *cc) {
char *cc = clean_content(content); int count = 0;
char *ccc = stripws(cc); char *ccc = cc;
char *cccp = ccc; char *cccp = ccc;
free(cc);
char *number_buffer = (char *)malloc(strlen(ccc) + 1); char *number_buffer = (char *)malloc(strlen(ccc) + 1);
*number_buffer = 0; *number_buffer = 0;
char *number_buffer_p = number_buffer; char *number_buffer_p = number_buffer;
sl *numbers = sln();
while (*cccp) { while (*cccp) {
if (isdigit((*cccp))) { if (isdigit((*cccp))) {
*number_buffer_p = *cccp; *number_buffer_p = *cccp;
number_buffer_p++; number_buffer_p++;
*number_buffer_p = 0; *number_buffer_p = 0;
} else if (number_buffer != number_buffer_p) { } else if (number_buffer != number_buffer_p) {
sla(numbers, number_buffer); count++;
*number_buffer = 0; *number_buffer = 0;
number_buffer_p = number_buffer; number_buffer_p = number_buffer;
} }
cccp++; cccp++;
} }
free(number_buffer); free(number_buffer);
free(ccc); return count;
return numbers;
} }
bool stricmp(char *word1, char *word2) {
while (*word1 && tolower(*word1) == tolower(*word2)) {
word1++;
word2++;
}
return *word1 == *word2;
}
bool containswordi(sl *words, char *word) {
for (uint i = 0; i < words->count; i++) {
if (stricmp(words->strings[i], word))
return true;
}
return false;
}
sl *get_forbidden_words(char *content) {
sl *words = get_words(content);
sl *found = sln();
for (int j = 0; forbidden_words[j] != NULL; j++) {
if (containswordi(words, forbidden_words[j])) {
rstring_list_add(found, forbidden_words[j]);
}
}
slf(words);
return found;
}
unsigned int total = 0; unsigned int total = 0;
char *readall(FILE *f) {
if (fseek(f, 0, SEEK_END) != 0) {
fclose(f);
return NULL;
}
size_t file_size = ftell(f);
if (file_size == (size_t)-1L) {
fclose(f);
return NULL;
}
if (fseek(f, 0, SEEK_SET) != 0) {
fclose(f);
return NULL;
}
char *buffer = (char *)malloc(file_size + 1);
if (!buffer) {
fclose(f);
return NULL;
}
size_t bytes_read = fread(buffer, 1, file_size, f);
buffer[bytes_read] = 0;
return buffer;
}
void analyze(FILE *f) { void analyze(FILE *f) {
if(!f){
// File doesn't exist
return;
}
total = total + 1; total = total + 1;
printf("#%u\n", total); printf("#%u\n", total);
char *data = fread_till_eof(f);
str_t *all = strn(1337);
char *sbuf = NULL;
char *data = readall(f);
if(!data)
return;
char *clean_data = clean_content(data); char *clean_data = clean_content(data);
int capitalized_words = 0;
free(clean_data); int fw = 0;
int words = get_words(data,&capitalized_words,&fw);
// All capitalized words int sentences = get_sentences(data);
sl *capitalized_words = get_capitalized_words(data); int numbers = get_numbers(clean_data);
ulonglong capitalized_words_count = capitalized_words->count;
printf("Capitalized words: %llu\n", capitalized_words_count);
if(show_capitalized)
sld(capitalized_words);
sbuf = slds(capitalized_words);
stra(all, sbuf);
free(sbuf);
sl *sentences = get_sentences(data);
// All sentences
printf("Sentences: %llu\n", sentences->count);
if(show_sentences)
sld(sentences);
sbuf = slds(sentences);
stra(all, sbuf);
free(sbuf);
sl *words = get_words(data);
// All words // All words
printf("Words: %llu\n", words->count); printf("Words: %d\n", words);
if(show_words)
sld(words); // All capitalized words
sbuf = slds(words); printf("Capitalized words: %d\n", capitalized_words);
stra(all, sbuf);
free(sbuf); // All sentences
printf("Sentences: %i\n", sentences);
// Numbers // Numbers
sl *numbers = get_numbers(data); printf("Numbers: %d\n", numbers);
printf("Numbers: %llu\n", numbers->count);
if(show_numbers)
sld(numbers);
sbuf = slds(numbers);
stra(all, sbuf);
free(sbuf);
// Forbidden words // Forbidden words
sl *fw = get_forbidden_words(data); printf("Forbidden words: %d\n", fw);
printf("Forbidden words: %llu\n", fw->count);
if(show_forbidden_words) if (words) {
sld(fw); double capitalized_word_percentage = 100 * ((double)capitalized_words / (double)words);
sbuf = slds(fw);
stra(all, sbuf);
free(sbuf);
strd(all);
if(words->count){
double capitalized_word_percentage = 100 * ((double)capitalized_words->count / (double)words->count);
printf("Capitalized percentage: %f%%\n", capitalized_word_percentage); printf("Capitalized percentage: %f%%\n", capitalized_word_percentage);
double forbidden_word_percentage = 100 * ((double)fw->count / (double)words->count); double forbidden_word_percentage = 100 * ((double)fw / (double)words);
printf("Forbidden percentage: %f%%\n", forbidden_word_percentage); printf("Forbidden percentage: %f%%\n", forbidden_word_percentage);
ulonglong word_count_per_sentence = words->count / (sentences->count ? sentences->count : 1); ulonglong word_count_per_sentence = words / (sentences ? sentences : 1);
printf("Word count per sentence: %llu\n", word_count_per_sentence); printf("Word count per sentence: %llu\n", word_count_per_sentence);
} }
slf(capitalized_words); free(clean_data);
slf(sentences);
slf(words);
slf(numbers);
slf(fw);
free(data); free(data);
} }
void analyze_file(char *path) { void analyze_file(char *path) {
FILE *f = fopen(path, "r"); FILE *f = fopen(path, "r");
if(f){
analyze(f); analyze(f);
fclose(f); fclose(f);
}else{
printf("File doesn't exist: %s\n",path);
}
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
if (argc > 1) { if (argc > 1) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
if(!strcmp(argv[1],"--hide-capitalized")){
show_capitalized=false;
}else if(!strcmp(argv[1],"--show-sentences")){
show_sentences=true;
}else if(!strcmp(argv[1],"--show-words")){
show_words=true;
}else if(!strcmp(argv[1],"--show-numbers")){
show_words=true;
}else if(!strcmp(argv[1],"--hide-forbidden-words")){
show_forbidden_words=false;
}else if(!strcmp(argv[1],"help") || !strcmp(argv[1],"--help")){
printf("%s",
"Usage: spam [file] [file] [file]\n"
"Flag defaults:\n"
" hide-capitalized = true\n"
" show-sentences = false\n"
" show-words = false\n"
" show-numbers = false\n"
" hide-forbidden-words = false\n");
return 0;
}
printf("File: %s\n", argv[i]); printf("File: %s\n", argv[i]);
analyze_file(argv[i]); analyze_file(argv[i]);
printf("%s\n", rmalloc_stats());
printf("\n"); printf("\n");
} }
return 0; return 0;

View File

@ -26,8 +26,6 @@ void stra(str_t *str, const char *to_append) {
if (required_new_length > str->size) { if (required_new_length > str->size) {
str->size += required_new_length + str->buffer_size; str->size += required_new_length + str->buffer_size;
str->content = (char *)realloc(str->content, str->size + 1); str->content = (char *)realloc(str->content, str->size + 1);
} else {
// printf("NO NDEED\n");
} }
strcat(str->content, to_append); strcat(str->content, to_append);
str->content[str->length] = 0; str->content[str->length] = 0;