Skip to content

Commit 188032e

Browse files
committed
upgrade Crystal
1 parent f09d1f9 commit 188032e

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The following results are for 123 unique utf-8 Bible text files in 23 languages
1818
2. Golang 1.22.0 = 1.40s, sorting with collations: 1.71s
1919
3. Python 3.12.2 = 5.69, sorting with collations: 6.04s
2020
4. Crystal 1.5.1 = 5.61s
21+
4. Crystal 1.11.2 = 13.27s
2122
5. Elixir 1.14.0 = 7.34s
2223
6. Julia 1.8.1 = 12.13s, sorting: 12.22s
2324
7. Ruby 3.3.0 = 12.63s, sorting with collations: 22.00s
@@ -29,15 +30,15 @@ The new optimized Golang code version is very fast, slower than Rust but faster
2930

3031
* Rust = the current example uses [lexical-sort](https://lib.rs/crates/lexical-sort) which is not perfect. [There is no standard mature implementation of i18n in Rust](https://www.arewewebyet.org/topics/i18n/) at the moment.
3132

32-
* Python = has a great implementation of [ICU](https://icu.unicode.org/related) library however it does not support arm64/M1 platform, hence I couldn't use it in this comparison.
33+
* Python = has a great implementation of [ICU](https://icu.unicode.org/related) library ~~however it does not support arm64/M1 platform, hence I couldn't use it in this comparison.~~
3334

34-
* Ruby = can sort unicode text but without collations becase it can't use ICU on arm64/M1
35+
* Ruby = can sort unicode text ~~but without collations becase it can't use ICU on arm64/M1~~ with collations but it slowes down the code almost 2x.
3536

36-
* Elixir = same as Python, no ICU for M1.
37+
* Elixir = no ICU for M1 to sort with collations.
3738

3839
* Julia = I couldn't find a good i18 library supporting many languages.
3940

40-
* Crystal = currently supports only Turkish collations. Probably because the language is young and does not have a large enough community or company behind it.
41+
* Crystal = currently supports only Turkish collations. Probably because the language is young and does not have a large enough community or company behind it (as March 2024 still no more collations)
4142

4243
* Golang = has rules for many languages. You can see the influence of a large company and community which makes Golang a mature solution. Sorting slowed the whole task down significantly, but the result is correct (in this case I only checked the results for the Polish language)
4344

@@ -54,6 +55,7 @@ The new optimized Golang code version is very fast, slower than Rust but faster
5455
* Updated Python version to 3.12.2, added poetry, solved missing icu4 collations for M1 processors, added a fancy progress bar
5556
* Updated Golang version to 1.22.0
5657
* Updated Ruby version to 3.3.0, added sorting with collations for many languages (this slowed the code almost 2x)
58+
* Updated Crystal version to 1.11.2 (using 10 cores is slower than 8 and uzsing 8 cofres is slower than 4, all is slower than v1.5.1, strange)
5759

5860
2022-09-17
5961

example-crystal/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
## setup and run
44

55
```
6-
crystal build --release -Dpreview_mt src/example-crystal.cr -o main
7-
CRYSTAL_WORKERS=8 ./main
6+
crystal build --release src/example-crystal.cr -o main
7+
CRYSTAL_WORKERS=4 ./main
88
```

example-crystal/shard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ targets:
88
example-crystal:
99
main: src/example-crystal.cr
1010

11-
crystal: 1.5.1
11+
crystal: 1.11.2
1212

1313
license: MIT

example-crystal/src/example-crystal.cr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ module Example::Crystal
1717
channel = Channel(Tuple(String, Int64)).new
1818
srcPath = "../data/??/**/*.yml"
1919
paths = Dir.glob(srcPath, follow_symlinks: true)
20+
2021
count = paths.size
2122
paths.each do |path|
23+
puts(::sprintf("[%3d/%3d] %s", file_count + 1, count, path))
2224
if concurrent
2325
spawn do
2426
channel.send worker(path, outdir, with_sorting)
@@ -50,6 +52,7 @@ module Example::Crystal
5052
end
5153

5254
meta = File.open(path) { |file| YAML.parse(file) }
55+
puts(path)
5356
outfilepath = %Q(#{outdir}/#{meta["lang"]}-#{meta["code"]}.txt)
5457
File.write(outfilepath, words.join("\n"))
5558
filesize = File.size(filepath)

0 commit comments

Comments
 (0)