netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
speedtest.c File Reference
`#include <errno.h>`
`#include <fcntl.h>`
`#include <getopt.h>`
`#include <math.h>`
`#include <signal.h>`
`#include <string.h>`
`#include <sys/mman.h>`
`#include <sys/stat.h>`
`#include <sys/time.h>`
`#include <sys/types.h>`
`#include <unistd.h>`
`#include <netinet/tcp.h>`
`#include <sys/socket.h>`
`#include "afpclient.h"`
`#include "afpcmd.h"`
`#include "afphelper.h"`
`#include "testhelper.h"`
`#include "afp_tcp_analytics.h"`
`#include "speedtest_local_vfs.h"`

## Data Structures
struct | TestStats
struct | SizeSweepResult
struct | AllTestResults
struct | test_entry

## Macros
#define | KILOBYTE 1024
#define | MEGABYTE (KILOBYTE*KILOBYTE)
#define | MAX_ITERATIONS 1000
#define | MAX_SIZE_SWEEP 32

## Enumerations
enum | OutputFormat { OUTPUT_TEXT , OUTPUT_CSV }

## Functions
int32_t | is_there (CONN *conn, uint16_t volume, int32_t did, char *name)
static void | press_enter (char *s)
| Display message and wait for user to press Enter.
unsigned long long | delta (void)
static int | compare_ulonglong (const void *a, const void *b)
| Compare function for qsort() to sort unsigned long long values.
static void | calculate_statistics (TestStats *stats)
| Calculate mean, median, stddev, and percentiles from timing samples.
static void | record_timing (unsigned long long microseconds)
| Record single timing measurement for current test.
static void | reset_statistics (void)
| Reset statistics counters for next test iteration.
static void | print_statistics_text (const char *test_name)
| Print statistics in human-readable text format.
static void | print_csv_header (void)
| Print CSV header row with column names.
static void | print_csv_statistics (const char *test_name, off_t file_size)
| Print CSV statistics row with mean, median, stddev, percentiles.
static void | run_one (char *name)
| Execute single test by name (Read/Write/Copy/ServerCopy).
static void | print_test_summary (const char *test_name, const SizeSweepResult *results, int result_count)
static void | print_size_sweep_tables (void)
| Print file size performance summary tables for all test types.
static void | run_one_with_size_sweep (char *test_name)
| Execute test with file size sweep mode enabled.
static void | print_and_collect_results (const char *test_name)
| Print results and collect statistics for size sweep mode.
static int | check_test_dir_exists (uint16_t vol, char *dir_name, const char *test_name)
static void | print_iteration_marker (int iteration, int display_iter)
| Print iteration number marker for progress tracking.
static void | print_test_header (const char *test_name)
| Print test header with name and configuration.
static void | header (void)
| Print test header with timestamp.
static void | timer_footer (const char *test_name, int iteration)
| Print timing results and record statistics after test iteration.
void | Write (void)
| Execute Write test with configured file size and iterations.
int | init_fork (uint16_t fork)
| Initialize fork by truncating to 0 then setting to File_size.
static int | getfd (CONN *conn, int fork)
| Get file descriptor from fork (AFP or Local mode).
void | Copy (void)
| Execute Copy test with configured file size and iterations.
void | ServerCopy (void)
| Execute ServerCopy test with configured file size and iterations.
void | Read (void)
| Execute Read test with configured file size and iterations.
void | usage (char *av0)
| Display usage information and exit.
int | main (int ac, char **av)
| Main entry point: parse arguments, setup connection, run tests.

## Variables
uint16_t | VolID
uint16_t | VolID2
static DSI * | dsi
CONN * | Conn
int | ExitCode = 0
DSI * | Dsi
char | Data [30000]
char * | Buffer
struct timeval | Timer_start
struct timeval | Timer_end
static TestStats | current_test_stats
static int | enable_statistics = 0
static int | in_warmup_phase = 0
static OutputFormat | output_format = OUTPUT_TEXT
static int | csv_header_printed = 0
static TcpAnalyticsSession | tcp_session
char * | Server = "localhost"
static int | Port = DSI_AFPOVERTCP_PORT
static char * | Password = ""
char * | Vol = ""
char * | Vol2 = ""
static char * | LocalPath = ""
char * | User
int | Version = 34
char * | Test = "Write"
static char * | Filename
char * | vers = "AFP3.4"
char * | uam = "Cleartxt Passwrd"
static int | Count = 1
static int | WarmupRuns = 1
static int | DelaySeconds = 0
static off_t | Size = 64 * MEGABYTE
static int | size_sweep_enabled = 0
static off_t | size_sweep_values [MAX_SIZE_SWEEP]
static int | size_sweep_count = 0
static AllTestResults | all_results
static size_t | Quantum = 0
static int | Request = 1
static int | Delete = 0
static int | Sparse = 0
static int | Local = 0
static int | Flush = 1
static int | Direct = 1
CONN * | Conn2
int | Mac = 0
int | EmptyVol = 0
int | PassCount = 0
int | FailCount = 0
int | SkipCount = 0
int | NotTestedCount = 0
char | FailedTests [1024][256] = {{0}}
char | NotTestedTests [1024][256] = {{0}}
char | SkippedTests [1024][256] = {{0}}
struct vfs | VFS
static struct test_entry | test_table []

## Macro Definition Documentation

## ◆ KILOBYTE

#define KILOBYTE 1024

## ◆ MAX_ITERATIONS

#define MAX_ITERATIONS 1000

## ◆ MAX_SIZE_SWEEP

#define MAX_SIZE_SWEEP 32

## ◆ MEGABYTE

#define MEGABYTE (KILOBYTE*KILOBYTE)

## Enumeration Type Documentation

## ◆ OutputFormat

enum OutputFormat

Enumerator
OUTPUT_TEXT |
OUTPUT_CSV |

## Function Documentation

## ◆ calculate_statistics()

void calculate_statistics | ( | TestStats * | stats | ) |
| static

Calculate mean, median, stddev, and percentiles from timing samples.

## ◆ check_test_dir_exists()

int check_test_dir_exists | ( | uint16_t | vol,
|  | char * | dir_name,
|  | const char * | test_name )
| static

## ◆ compare_ulonglong()

int compare_ulonglong | ( | const void * | a,
|  | const void * | b )
| static

Compare function for qsort() to sort unsigned long long values.

## ◆ Copy()

void Copy | ( | void |  | ) |

Execute Copy test with configured file size and iterations.

## ◆ delta()

unsigned long long delta | ( | void |  | ) |

## ◆ getfd()

int getfd | ( | CONN * | conn,
|  | int | fork )
| static

Get file descriptor from fork (AFP or Local mode).

## ◆ header()

void header | ( | void |  | ) |
| static

Print test header with timestamp.

## ◆ init_fork()

int init_fork | ( | uint16_t | fork | ) |

Initialize fork by truncating to 0 then setting to File_size.

## ◆ is_there()

int32_t is_there | ( | CONN * | conn,
|  | uint16_t | volume,
|  | int32_t | did,
|  | char * | name )

## ◆ main()

int main | ( | int | ac,
|  | char ** | av )

Main entry point: parse arguments, setup connection, run tests.

## ◆ press_enter()

void press_enter | ( | char * | s | ) |
| static

Display message and wait for user to press Enter.

## ◆ print_and_collect_results()

void print_and_collect_results | ( | const char * | test_name | ) |
| static

Print results and collect statistics for size sweep mode.

## ◆ print_csv_header()

void print_csv_header | ( | void |  | ) |
| static

Print CSV header row with column names.

## ◆ print_csv_statistics()

void print_csv_statistics | ( | const char * | test_name,
|  | off_t | file_size )
| static

Print CSV statistics row with mean, median, stddev, percentiles.

## ◆ print_iteration_marker()

void print_iteration_marker | ( | int | iteration,
|  | int | display_iter )
| static

Print iteration number marker for progress tracking.

## ◆ print_size_sweep_tables()

void print_size_sweep_tables | ( | void |  | ) |
| static

Print file size performance summary tables for all test types.

## ◆ print_statistics_text()

void print_statistics_text | ( | const char * | test_name | ) |
| static

Print statistics in human-readable text format.

## ◆ print_test_header()

void print_test_header | ( | const char * | test_name | ) |
| static

Print test header with name and configuration.

## ◆ print_test_summary()

void print_test_summary | ( | const char * | test_name,
|  | const SizeSweepResult * | results,
|  | int | result_count )
| static

## ◆ Read()

void Read | ( | void |  | ) |

Execute Read test with configured file size and iterations.

## ◆ record_timing()

void record_timing | ( | unsigned long long | microseconds | ) |
| static

Record single timing measurement for current test.

## ◆ reset_statistics()

void reset_statistics | ( | void |  | ) |
| static

Reset statistics counters for next test iteration.

## ◆ run_one()

void run_one | ( | char * | name | ) |
| static

Execute single test by name (Read/Write/Copy/ServerCopy).

## ◆ run_one_with_size_sweep()

void run_one_with_size_sweep | ( | char * | test_name | ) |
| static

Execute test with file size sweep mode enabled.

## ◆ ServerCopy()

void ServerCopy | ( | void |  | ) |

Execute ServerCopy test with configured file size and iterations.

## ◆ timer_footer()

void timer_footer | ( | const char * | test_name,
|  | int | iteration )
| static

Print timing results and record statistics after test iteration.

## ◆ usage()

void usage | ( | char * | av0 | ) |

Display usage information and exit.

## ◆ Write()

void Write | ( | void |  | ) |

Execute Write test with configured file size and iterations.

## Variable Documentation

## ◆ all_results

AllTestResults all_results
| static

## ◆ Buffer

char* Buffer

## ◆ Conn

CONN* Conn

## ◆ Conn2

CONN* Conn2

## ◆ Count

int Count = 1
| static

## ◆ csv_header_printed

int csv_header_printed = 0
| static

## ◆ current_test_stats

TestStats current_test_stats
| static

## ◆ Data

char Data[30000]

## ◆ DelaySeconds

int DelaySeconds = 0
| static

## ◆ Delete

int Delete = 0
| static

## ◆ Direct

int Direct = 1
| static

## ◆ Dsi

DSI* Dsi

## ◆ dsi

DSI* dsi
| static

## ◆ EmptyVol

int EmptyVol = 0

## ◆ enable_statistics

int enable_statistics = 0
| static

## ◆ ExitCode

int ExitCode = 0

## ◆ FailCount

int FailCount = 0

## ◆ FailedTests

char FailedTests[1024][256] = {{0}}

## ◆ Filename

char* Filename
| static

## ◆ Flush

int Flush = 1
| static

## ◆ in_warmup_phase

int in_warmup_phase = 0
| static

## ◆ Local

int Local = 0
| static

## ◆ LocalPath

char* LocalPath = ""
| static

## ◆ Mac

int Mac = 0

## ◆ NotTestedCount

int NotTestedCount = 0

## ◆ NotTestedTests

char NotTestedTests[1024][256] = {{0}}

## ◆ output_format

OutputFormat output_format = OUTPUT_TEXT
| static

## ◆ PassCount

int PassCount = 0

## ◆ Password

char* Password = ""
| static

## ◆ Port

int Port = DSI_AFPOVERTCP_PORT
| static

## ◆ Quantum

size_t Quantum = 0
| static

## ◆ Request

int Request = 1
| static

## ◆ Server

char* Server = "localhost"

## ◆ Size

off_t Size = 64 * MEGABYTE
| static

## ◆ size_sweep_count

int size_sweep_count = 0
| static

## ◆ size_sweep_enabled

int size_sweep_enabled = 0
| static

## ◆ size_sweep_values

off_t size_sweep_values[MAX_SIZE_SWEEP]
| static

## ◆ SkipCount

int SkipCount = 0

## ◆ SkippedTests

char SkippedTests[1024][256] = {{0}}

## ◆ Sparse

int Sparse = 0
| static

## ◆ tcp_session

TcpAnalyticsSession tcp_session
| static

## ◆ Test

char* Test = "Write"

## ◆ test_table

struct test_entry test_table[]
| static

Initial value:
= {
{ "Read", Read },
{ "Write", Write },
{ "Copy", Copy },
{ "ServerCopy", ServerCopy },
{ NULL, NULL }
}
Read
void Read(void)
Execute Read test with configured file size and iterations.
Definition speedtest.c:1435
Copy
void Copy(void)
Execute Copy test with configured file size and iterations.
Definition speedtest.c:1003
Write
void Write(void)
Execute Write test with configured file size and iterations.
Definition speedtest.c:789
ServerCopy
void ServerCopy(void)
Execute ServerCopy test with configured file size and iterations.
Definition speedtest.c:1294
NULL
#define NULL
Definition utf8util.c:47

## ◆ Timer_end

struct timeval Timer_end

## ◆ Timer_start

struct timeval Timer_start

## ◆ uam

char* uam = "Cleartxt Passwrd"

## ◆ User

char* User

## ◆ vers

char* vers = "AFP3.4"

## ◆ Version

int Version = 34

## ◆ VFS

struct vfs VFS

Initial value:
= {
FPGetFileDirParams,
FPCreateDir,
FPCreateFile,
FPOpenFork,
FPWriteHeader,
FPWriteFooter,
FPFlushFork,
FPCloseFork,
FPDelete,
FPSetForkParam,
FPWrite,
FPRead,
FPReadHeader,
FPReadFooter,
FPCopyFile,
FPOpenVol,
FPCloseVol
}
FPWriteFooter
unsigned int FPWriteFooter(DSI *dsi, uint16_t fork, int offset, int size, char *data, char whence)
Definition afpcmd.c:2410
FPGetFileDirParams
unsigned int FPGetFileDirParams(CONN *conn, uint16_t vol, int did, char *name, uint16_t f_bitmap, uint16_t d_bitmap)
Definition afpcmd.c:1321
FPReadFooter
unsigned int FPReadFooter(DSI *dsi, uint16_t fork, int offset, int size, char *data)
Definition afpcmd.c:2324
FPCloseFork
unsigned int FPCloseFork(CONN *conn, uint16_t vol)
Definition afpcmd.c:1069
FPRead
unsigned int FPRead(CONN *conn, uint16_t fork, long long offset, int size, char *data)
Definition afpcmd.c:2340
FPCreateFile
unsigned int FPCreateFile(CONN *conn, uint16_t vol, char type, int did, char *name)
Definition afpcmd.c:1837
FPDelete
unsigned int FPDelete(CONN *conn, uint16_t vol, int did, char *name)
Definition afpcmd.c:1674
FPReadHeader
unsigned int FPReadHeader(DSI *dsi, uint16_t fork, int offset, int size, char *data)
Definition afpcmd.c:2308
FPCreateDir
unsigned int FPCreateDir(CONN *conn, uint16_t vol, int did, char *name)
Definition afpcmd.c:1794
FPCopyFile
unsigned int FPCopyFile(CONN *conn, uint16_t svol, int sdid, uint16_t dvol, int ddid, char *src, char *dstdir, char *dst)
Definition afpcmd.c:2155
FPOpenVol
uint16_t FPOpenVol(CONN *conn, char *vol)
Definition afpcmd.c:830
FPCloseVol
unsigned int FPCloseVol(CONN *conn, uint16_t vol)
Definition afpcmd.c:836
FPOpenFork
uint16_t FPOpenFork(CONN *conn, uint16_t vol, int type, uint16_t bitmap, int did, char *name, int access)
Definition afpcmd.c:1813
FPFlushFork
unsigned int FPFlushFork(CONN *conn, uint16_t vol)
Definition afpcmd.c:1139
FPWrite
unsigned int FPWrite(CONN *conn, uint16_t fork, long long offset, int size, char *data, char whence)
Definition afpcmd.c:2426
FPSetForkParam
unsigned int FPSetForkParam(CONN *conn, uint16_t fork, uint16_t bitmap, off_t size)
Definition afpcmd.c:1925
FPWriteHeader
unsigned int FPWriteHeader(DSI *dsi, uint16_t fork, int offset, int size, char *data, char whence)
Definition afpcmd.c:2394

## ◆ Vol

char* Vol = ""

## ◆ Vol2

char* Vol2 = ""

## ◆ VolID

uint16_t VolID

## ◆ VolID2

uint16_t VolID2

## ◆ WarmupRuns

int WarmupRuns = 1
| static