Skip to content

Stream wrapper slower than the direct API #81

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);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions