···
3
3
true-s
4
4
true-zig
5
5
true-zig.o
6
6
+
true-lean
···
1
1
+
// Lean compiler output
2
2
+
// Module: True
3
3
+
// Imports: Init
4
4
+
#include <lean/lean.h>
5
5
+
#if defined(__clang__)
6
6
+
#pragma clang diagnostic ignored "-Wunused-parameter"
7
7
+
#pragma clang diagnostic ignored "-Wunused-label"
8
8
+
#elif defined(__GNUC__) && !defined(__CLANG__)
9
9
+
#pragma GCC diagnostic ignored "-Wunused-parameter"
10
10
+
#pragma GCC diagnostic ignored "-Wunused-label"
11
11
+
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
12
12
+
#endif
13
13
+
#ifdef __cplusplus
14
14
+
extern "C" {
15
15
+
#endif
16
16
+
LEAN_EXPORT lean_object* _lean_main(lean_object*);
17
17
+
LEAN_EXPORT lean_object* l_main___boxed__const__1;
18
18
+
static lean_object* _init_l_main___boxed__const__1() {
19
19
+
_start:
20
20
+
{
21
21
+
uint32_t x_1; lean_object* x_2;
22
22
+
x_1 = 0;
23
23
+
x_2 = lean_box_uint32(x_1);
24
24
+
return x_2;
25
25
+
}
26
26
+
}
27
27
+
LEAN_EXPORT lean_object* _lean_main(lean_object* x_1) {
28
28
+
_start:
29
29
+
{
30
30
+
lean_object* x_2; lean_object* x_3;
31
31
+
x_2 = l_main___boxed__const__1;
32
32
+
x_3 = lean_alloc_ctor(0, 2, 0);
33
33
+
lean_ctor_set(x_3, 0, x_2);
34
34
+
lean_ctor_set(x_3, 1, x_1);
35
35
+
return x_3;
36
36
+
}
37
37
+
}
38
38
+
lean_object* initialize_Init(uint8_t builtin, lean_object*);
39
39
+
static bool _G_initialized = false;
40
40
+
LEAN_EXPORT lean_object* initialize_True(uint8_t builtin, lean_object* w) {
41
41
+
lean_object * res;
42
42
+
if (_G_initialized) return lean_io_result_mk_ok(lean_box(0));
43
43
+
_G_initialized = true;
44
44
+
res = initialize_Init(builtin, lean_io_mk_world());
45
45
+
if (lean_io_result_is_error(res)) return res;
46
46
+
lean_dec_ref(res);
47
47
+
l_main___boxed__const__1 = _init_l_main___boxed__const__1();
48
48
+
lean_mark_persistent(l_main___boxed__const__1);
49
49
+
return lean_io_result_mk_ok(lean_box(0));
50
50
+
}
51
51
+
char ** lean_setup_args(int argc, char ** argv);
52
52
+
void lean_initialize_runtime_module();
53
53
+
54
54
+
#if defined(WIN32) || defined(_WIN32)
55
55
+
#include <windows.h>
56
56
+
#endif
57
57
+
58
58
+
int main(int argc, char ** argv) {
59
59
+
#if defined(WIN32) || defined(_WIN32)
60
60
+
SetErrorMode(SEM_FAILCRITICALERRORS);
61
61
+
SetConsoleOutputCP(CP_UTF8);
62
62
+
#endif
63
63
+
lean_object* in; lean_object* res;
64
64
+
argv = lean_setup_args(argc, argv);
65
65
+
lean_initialize_runtime_module();
66
66
+
lean_set_panic_messages(false);
67
67
+
res = initialize_True(1 /* builtin */, lean_io_mk_world());
68
68
+
lean_set_panic_messages(true);
69
69
+
lean_io_mark_end_initialization();
70
70
+
if (lean_io_result_is_ok(res)) {
71
71
+
lean_dec_ref(res);
72
72
+
lean_init_task_manager();
73
73
+
res = _lean_main(lean_io_mk_world());
74
74
+
}
75
75
+
lean_finalize_task_manager();
76
76
+
if (lean_io_result_is_ok(res)) {
77
77
+
int ret = lean_unbox_uint32(lean_io_result_get_value(res));
78
78
+
lean_dec_ref(res);
79
79
+
return ret;
80
80
+
} else {
81
81
+
lean_io_result_show_error(res);
82
82
+
lean_dec_ref(res);
83
83
+
return 1;
84
84
+
}
85
85
+
}
86
86
+
#ifdef __cplusplus
87
87
+
}
88
88
+
#endif
···
1
1
+
2
2
+
def main : IO UInt32 := pure 0
···
1
1
How much pain will the programmer take to make the program run fast?
2
2
3
3
-
| Command | Mean [µs] | Min [µs] | Max [µs] | Relative |
4
4
-
|:---|---:|---:|---:|---:|
5
5
-
| `true` | 272.6 ± 27.3 | 235.1 | 564.7 | 3.40 ± 0.74 |
6
6
-
| `./true-s` | 80.2 ± 15.6 | 70.0 | 671.2 | 1.00 |
7
7
-
| `./true-zig` | 85.5 ± 14.9 | 74.2 | 385.7 | 1.07 ± 0.28 |
8
8
-
| `./true-hare` | 92.7 ± 18.1 | 80.5 | 1041.3 | 1.16 ± 0.32 |
9
9
-
| `./true-go` | 564.8 ± 43.6 | 484.6 | 2070.5 | 7.04 ± 1.47 |
3
3
+
See [timings](timings.md).
4
4
+
···
7
7
8
8
go build -o true-go true.go
9
9
10
10
-
hyperfine --export-markdown timings.md -N 'true' './true-s' './true-zig' './true-hare' './true-go'
10
10
+
lean -cTrue.c True.lean
11
11
+
leanc -O3 -o true-lean True.c
12
12
+
13
13
+
hyperfine --export-markdown timings.md -N 'true' './true-s' './true-zig' './true-hare' './true-go' './true-lean'
···
1
1
| Command | Mean [µs] | Min [µs] | Max [µs] | Relative |
2
2
|:---|---:|---:|---:|---:|
3
3
-
| `true` | 272.6 ± 27.3 | 235.1 | 564.7 | 3.40 ± 0.74 |
4
4
-
| `./true-s` | 80.2 ± 15.6 | 70.0 | 671.2 | 1.00 |
5
5
-
| `./true-zig` | 85.5 ± 14.9 | 74.2 | 385.7 | 1.07 ± 0.28 |
6
6
-
| `./true-hare` | 92.7 ± 18.1 | 80.5 | 1041.3 | 1.16 ± 0.32 |
7
7
-
| `./true-go` | 564.8 ± 43.6 | 484.6 | 2070.5 | 7.04 ± 1.47 |
3
3
+
| `true` | 272.9 ± 31.2 | 238.0 | 933.2 | 3.35 ± 1.43 |
4
4
+
| `./true-s` | 81.5 ± 33.5 | 71.5 | 1460.9 | 1.00 |
5
5
+
| `./true-zig` | 87.1 ± 43.1 | 76.7 | 1748.2 | 1.07 ± 0.69 |
6
6
+
| `./true-hare` | 94.7 ± 48.2 | 84.1 | 1904.5 | 1.16 ± 0.76 |
7
7
+
| `./true-go` | 579.1 ± 133.1 | 499.8 | 4066.2 | 7.11 ± 3.34 |
8
8
+
| `./true-lean` | 1632.5 ± 75.0 | 1519.5 | 2243.9 | 20.04 ± 8.28 |