Skip to content

Conversation

@JackStouffer
Copy link
Contributor

In the vein of #5413 and #5404

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @JackStouffer!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@JackStouffer JackStouffer force-pushed the DateTime-fromstring branch from 2adb329 to 58ebf54 Compare July 5, 2017 19:10
@JackStouffer
Copy link
Contributor Author

JackStouffer commented Jul 6, 2017

Speed results

# old
$ git checkout master
$ dmd/src/dmd -O -inline -release test.d && ./test
result	6 secs, 83 ms, 931 μs, and 1 hnsec

# new
$ git checkout DateTime-fromstring
$ dmd/src/dmd -O -inline -release test.d && ./test
result	1 sec, 746 ms, and 330 μs

code

import std.stdio;
import std.algorithm;
import std.conv;
import std.traits;
import std.datetime;

enum testCount = 5_000_000;


void main()
{
    auto result = to!Duration(benchmark!(() => DateTime.fromISOString("20100704T070612"))(testCount)[0]);

    writeln("result", "\t", result);
}

import std.string : strip;

immutable dstr = to!dstring(strip(isoString));
immutable str = strip(isoString);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work to use byCodeUnit here? Presumably, the speed-up is from getting rid of allocating the dstring, but you're introducing more auto-decoding in the process. If byCodeUnit doesn't work here at the moment (e.g. due to a function still requiring actual strings), then this is still clearly better, but I'd prefer to have byCodeUnit used if we can.

Copy link
Contributor Author

@JackStouffer JackStouffer Jul 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmdavis None of the functions here use auto decoding. I've already removed it from Date.fromISOString and TimeOfDay.fromISOString, and countUntil with a single needle forwards to find, which already deals with auto-decoding.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that strip and countUntil both did, but if they don't, then that's not an issue (though actually, I should probably know for strip, since I did a rewrite of that at one point - but I guess that it was long enough ago that I forgot).

@dlang-bot dlang-bot merged commit 24e2f9e into dlang:master Jul 8, 2017
@JackStouffer
Copy link
Contributor Author

@jmdavis Thanks!

@JackStouffer JackStouffer deleted the DateTime-fromstring branch July 8, 2017 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants