Display request time - clic - Clic is an command line interactive client for gopher written in Common LISP
HTML git clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/clic/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit ce56b40eb8ee913c000bdb5287d03227cca10a61
DIR parent 8728b1f94663cfc4f8c6eb664263e8b216f8b3e5
HTML Author: Solene Rapenne <solene@perso.pw>
Date: Wed, 31 Jan 2018 11:57:11 +0100
Display request time
Diffstat:
M clic.lisp | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
---
DIR diff --git a/clic.lisp b/clic.lisp
@@ -58,6 +58,9 @@
;;; altered by (add-bookmark) and (load-bookmark)
(defparameter *bookmarks* nil)
+;;; contain duration of the last request
+(defparameter *duration* 0)
+
;;; when clic loads a type 1 page, we store location structures here
;;; when clic display the bookmark, we store bookmarks locations here
(defparameter *links* (make-hash-table))
@@ -253,7 +256,8 @@
;; we prepare informations about the connection
(let* ((address (sb-bsd-sockets:get-host-by-name host))
(host (car (sb-bsd-sockets:host-ent-addresses address)))
- (socket (make-instance 'sb-bsd-sockets:inet-socket :type :stream :protocol :tcp)))
+ (socket (make-instance 'sb-bsd-sockets:inet-socket :type :stream :protocol :tcp))
+ (real-time (get-internal-real-time)))
(sb-bsd-sockets:socket-connect socket host port)
@@ -303,7 +307,11 @@
(loop for line = (read-line stream nil nil)
while line
do
- (vector-push line *buffer*))))))
+ (vector-push line *buffer*))))
+
+ ;; we store the duration of the connection
+ (setf *duration* (float (/ (- (get-internal-real-time) real-time)
+ internal-time-units-per-second)))))
(defun g(key)
"browse to the N-th link"
@@ -642,11 +650,12 @@
(defun display-prompt()
(let ((last-page (car *history*)))
- (format t "gopher://~a:~a/~a~a / (P)rev (R)eload (B)ookmark (H)istory : "
+ (format t "gopher://~a:~a/~a~a (~as) / (P)rev (R)eload (B)ookmark (H)istory : "
(location-host last-page)
(location-port last-page)
(location-type last-page)
- (location-uri last-page)))
+ (location-uri last-page)
+ *duration*))
(force-output))
(defun shell()