Skip to content

Loading…

DBAL-850: [GH-555] Improved performance of BlobType #2088

Closed
doctrinebot opened this Issue · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of BenMorel:

Url: #555

Message:

I noticed that the string to resource conversion code in BlobType uses a quite inefficient technique.
This PR improves its performance with a simple change involving the php://temp stream.

Quick benchmark of the two approaches, converting a 10MB string:

$value = str_repeat('x', 10 ** 1024 ** 1024);

$t = microtime(true);
$fp = fopen('data://text/plain;base64,' . base64_encode($value), 'r');
printf("%.3fs\n", microtime(true) - $t);

$t = microtime(true);
$fp = fopen('php://temp', 'rb+');
fwrite($fp, $value);
fseek($fp, 0);
printf("%.3fs\n", microtime(true) - $t);

Results on my laptop:

0.090s
0.008s

A tenfold improvement!

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-555] was closed:
#555

@doctrinebot

Comment created by @deeky666:

Fixed in commit: a077707

@doctrinebot

Issue was closed with resolution "Fixed"

@deeky666 deeky666 was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.5 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.