-
Notifications
You must be signed in to change notification settings - Fork 40
/
hello.lisp
executable file
·32 lines (25 loc) · 827 Bytes
/
hello.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/sbcl --script
(declaim (inline plusone))
(sb-alien:define-alien-routine plusone int (x int))
(sb-alien:define-alien-routine current_timestamp long-long)
(sb-alien:load-shared-object "newplus/libnewplus.so")
(defun run (count)
(declare (optimize (speed 3) (debug 0) (safety 0)))
(check-type count (unsigned-byte 31))
(let ((x 0)
(start (current_timestamp)))
(dotimes (i count)
(setf x (plusone x)))
(let ((end (current_timestamp)))
(format t "~d~%" (- end start)))))
#+(or)
(run 500000000)
(let* ((args sb-ext:*posix-argv*)
(count-arg (second args)))
(unless count-arg
(error "Argument is required"))
(let ((count (parse-integer count-arg)))
(if (and (plusp count)
(<= count 2e9))
(run count)
(error "Count must be from 1 to 2G."))))