Debian Codegraph @

tests/benchmarks/benchmarks.h

raw
1 /*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2010 by Aris Adamantiadis
5 *
6 * The SSH Library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or (at your
9 * option) any later version.
10 *
11 * The SSH Library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 * License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with the SSH Library; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19 * MA 02111-1307, USA.
20 */
21
22 #ifndef BENCHMARKS_H_
23 #define BENCHMARKS_H_
24
25 #include <libssh/libssh.h>
26
27 /* benchmarks.c */
28
29 /* maximum number of parallel hosts that may be checked */
30 #define MAX_HOSTS_CONNECT 20
31
32 enum libssh_benchmarks {
33 BENCHMARK_RAW_UPLOAD=0,
34 BENCHMARK_RAW_DOWNLOAD,
35 BENCHMARK_SCP_UPLOAD,
36 BENCHMARK_SCP_DOWNLOAD,
37 BENCHMARK_SYNC_SFTP_UPLOAD,
38 BENCHMARK_SYNC_SFTP_DOWNLOAD,
39 BENCHMARK_ASYNC_SFTP_DOWNLOAD,
40 BENCHMARK_ASYNC_SFTP_AIO_DOWNLOAD,
41 BENCHMARK_ASYNC_SFTP_AIO_UPLOAD,
42 BENCHMARK_NUMBER
43 };
44
45 struct argument_s {
46 const char *hosts[MAX_HOSTS_CONNECT];
47 int verbose;
48 int nhosts;
49 int ntests;
50 unsigned int datasize;
51 unsigned int chunksize;
52 int concurrent_requests;
53 char *cipher;
54 };
55
56 extern char *buffer;
57
58 typedef int (*bench_fct)(ssh_session session, struct argument_s *args,
59 float *bps);
60
61 struct benchmark {
62 const char *name;
63 bench_fct fct;
64 int enabled;
65 };
66
67 /* latency.c */
68
69 struct timestamp_struct {
70 struct timeval timestamp;
71 };
72
73 int benchmarks_ping_latency (const char *host, float *average);
74 int benchmarks_ssh_latency (ssh_session session, float *average);
75
76 void timestamp_init(struct timestamp_struct *ts);
77 float elapsed_time(struct timestamp_struct *ts);
78
79 /* bench_raw.c */
80
81 int benchmarks_raw_up (ssh_session session, struct argument_s *args,
82 float *bps);
83 int benchmarks_raw_down (ssh_session session, struct argument_s *args,
84 float *bps);
85
86 /* bench_scp.c */
87
88 int benchmarks_scp_up (ssh_session session, struct argument_s *args,
89 float *bps);
90 int benchmarks_scp_down (ssh_session session, struct argument_s *args,
91 float *bps);
92
93 /* bench_sftp.c */
94
95 int benchmarks_sync_sftp_up (ssh_session session, struct argument_s *args,
96 float *bps);
97 int benchmarks_sync_sftp_down (ssh_session session, struct argument_s *args,
98 float *bps);
99 int benchmarks_async_sftp_down (ssh_session session, struct argument_s *args,
100 float *bps);
101 int benchmarks_async_sftp_aio_down(ssh_session session, struct argument_s *args,
102 float *bps);
103 int benchmarks_async_sftp_aio_up(ssh_session session, struct argument_s *args,
104 float *bps);
105 #endif /* BENCHMARKS_H_ */