-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.el
223 lines (192 loc) · 6.31 KB
/
test.el
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-x C-f and enter text in its buffer.
;; (add-to-list 'load-path "~/work/tramp-libssh/build")
;; (require 'emacs-libssh)
;; (defun test-emacs-libssh-get-session ()
;; (interactive)
;; (message "get session")
;; (setq libssh-session (emacs-libssh-get-ssh-session nil "dev"))
;; (message "get sftp")
;; (setq libssh-sftp (emacs-libssh-get-sftp-session libssh-session))
;; )
;; (defun test-emacs-libssh-insert ()
;; (interactive)
;; (message "sftp insert")
;; (emacs-libssh-sftp-insert libssh-session libssh-sftp "/home/jsadusk/.bashrc" -1 -1)
;; )
;; (defun test-emacs-libssh-insert-region ()
;; (interactive)
;; (message "sftp insert 20 - 500")
;; (emacs-libssh-sftp-insert libssh-session libssh-sftp "/home/jsadusk/.bashrc" 23 590)
;; )
;; (defun test-emacs-libssh-write-region ()
;; (interactive)
;; (message "sftp write 20 - 500")
;; (emacs-libssh-sftp-write-region libssh-session libssh-sftp "/home/jsadusk/test_libssh.txt" 20 500 0)
;; )
;; (let ((dissected (tramp-dissect-file-name "/ssh:[email protected]:/home/joe/hello.txt")))
;; (message (prin1-to-string dissected))
;; )
(defun get-t (arg)
;(message "hello")
t
)
(message (concat "here i am again " (elt argv 0)))
(add-to-list 'load-path "~/work/tramp-libssh")
(setq testhost "jsadusk@dev")
(setq testdir "/home/jsadusk/")
(setq testpath (concat "/ssh:" testhost ":" testdir))
(setq testfilename "missing.yaml")
(setq testfilepath (concat testpath testfilename))
(setq module-path "/Users/jsadusk/work/tramp-libssh/target/release/libtramp_libssh.dylib")
(setq module-mtime -1)
(message testfilepath)
;(require 'rs-module)
(load module-path)
(load "/Users/jsadusk/work/tramp-libssh/build/emacs-libssh.so")
(defun load-if-changed()
"load if the module has changed"
;(if (file-has-changed-p module-path)
;(rs-module/load module-path)
;(message "not changed")
;)
)
(require 'benchmark)
(defun test-libssh-insert-from-file ()
(interactive)
(load-if-changed)
(message (prin1-to-string (tramp-dissect-file-name "/ssh:[email protected]:/home/joe/data.txt")))
(benchmark-run 1
(tramp-libssh-insert-file-contents "/ssh:[email protected]:/home/joe/data.txt" nil 4 15 nil)
)
)
(defun test-libssh-replace-from-file ()
(interactive)
(load-if-changed)
(message (prin1-to-string (tramp-dissect-file-name "/ssh:[email protected]:/home/joe/data.txt")))
(tramp-libssh-insert-file-contents "/ssh:[email protected]:/home/joe/data.txt" nil 4 15 t)
)
(defun test-libssh-write-buffer ()
(interactive)
(load-if-changed)
(message (prin1-to-string
(benchmark-elapse
(tramp-libssh-write-region nil nil testfilepath nil nil nil nil)
)
))
)
(defun test-libssh-write-buffer-append ()
(interactive)
(load-if-changed)
(tramp-libssh-write-region nil nil testfilepath t nil nil nil)
)
(defun test-libssh-file-exists ()
(interactive)
(load-if-changed)
(message (prin1-to-string
(benchmark-elapse
(message (prin1-to-string (tramp-libssh-file-exists-p testfilepath)))
)))
(message (prin1-to-string
(benchmark-elapse
(message (prin1-to-string (tramp-libssh-file-exists-p "/ssh:[email protected]:/home/joe/blarh.txt")))
)))
(message (prin1-to-string
(benchmark-elapse
(message (prin1-to-string (file-exists-p testfilepath)))
)))
(message (prin1-to-string
(benchmark-elapse
(message (prin1-to-string (file-exists-p "/ssh:[email protected]:/home/joe/blarh.txt")))
)))
)
(defun test-directory-files ()
(interactive)
(load-if-changed)
(message (prin1-to-string (tramp-libssh-directory-files "/ssh:[email protected]:/home/joe/" nil nil nil nil)))
)
(defun test-directory-files-and-attributes ()
(interactive)
(load-if-changed)
(message (prin1-to-string (tramp-libssh-directory-files-and-attributes "/ssh:[email protected]:/home/joe/" nil nil nil 'string nil)))
)
(defun test-directory-files-and-attributes-fulldir ()
(interactive)
(load-if-changed)
(message (prin1-to-string (tramp-libssh-directory-files-and-attributes "/ssh:[email protected]:/home/joe/" t nil nil 'string nil)))
)
(defun test-directory-files-fulldir ()
(interactive)
(load-if-changed)
(message (prin1-to-string (tramp-libssh-directory-files "/ssh:[email protected]:/home/joe/" t nil nil nil)))
)
(defun test-directory-files-rexexp ()
(interactive)
(load-if-changed)
(message (prin1-to-string (tramp-libssh-directory-files "/ssh:[email protected]:/home/joe/" nil "^s.*t" nil nil)))
)
(defun test-directory-files-count ()
(interactive)
(load-if-changed)
(message (prin1-to-string (tramp-libssh-directory-files "/ssh:[email protected]:/home/joe/" nil nil nil 5)))
)
(defun test-delete-file ()
(interactive)
(load-if-changed)
(tramp-libssh-delete-file testfilepath nil)
)
(defun test-file-attributes()
(interactive)
(load-if-changed)
(message (prin1-to-string (tramp-libssh-file-attributes testfilepath 'string)))
)
(defun test-call-process()
(interactive)
(load-if-changed)
(message testpath)
(let ((default-directory "/ssh:[email protected]:/home/joe"))
(message default-directory)
(message "libssh")
(message (prin1-to-string
(benchmark-elapse
(tramp-libssh-process-file "ls" nil "output" nil '("-l" "/usr"))
)))
(message (prin1-to-string
(benchmark-elapse
(tramp-libssh-process-file "ls" nil "output" nil '("-l" "/usr"))
)))
(message (prin1-to-string
(benchmark-elapse
(tramp-libssh-process-file "ls" nil "output" nil '("-l" "/usr"))
)))
(message "tramp")
(message default-directory)
(message (prin1-to-string
(benchmark-elapse
(process-file "ls" nil "output" nil "-l" "/usr")
)))
)
)
(defun bare-lisp (arg)
(dotimes (i 10000)
(get-t arg)
)
)
(defun test-bare ()
(interactive)
(load-if-changed)
(message "rust")
(message (prin1-to-string
(benchmark-elapse
(tramp-libssh-bare "hello"))))
(message "lisp")
(message (prin1-to-string
(benchmark-elapse
(bare-lisp "hello"))))
(message "C")
(message (prin1-to-string
(benchmark-elapse
(emacs-libssh-test-bare "hello"))))
)
;(message (read-string "hello: " nil nil nil nil))\
;(message (read-passwd "asdf: " 't))