Skip to content

Stream wrapper slower than the direct API #81

@georgschoelly

Description

@georgschoelly

Overview

The stream wrappers are really useful. However, we noticed that copy operations are much slower. The client runs on Linux and the server on Windows.

For a 65 MB file we took the following measurements:

Tool Time
smbclient (CLI) 2.3s
stream copy() 47s
stream fwrite() 47s
smbclient_write 3s

Code

stream copy

copy("/path/to/file", "smb://server/C/testfile");

stream fwrite

$f_in = fopen("/path/to/file", "r");
$f_out = fopen("smb://server/C/testfile", "w");

while (!feof($f_in))
       fwrite($f_out, fread($f_in, 10*1024*1024));

smbclient_write

$state = smbclient_state_new();
smbclient_state_init($state);

$file = smbclient_creat($state, 'smb://server/C/testfile');
$f_in = fopen("/path/to/file", "r");

while (!feof($f_in)) {
        $data = fread($f_in, 10*1024*1024);
        smbclient_write($state, $file, $data);
}
smbclient_close($state, $file);
smbclient_state_free($state);

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions