Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SplitInHalf is expensive, should use ropes #40

Open
zcorpan opened this issue Jan 5, 2017 · 1 comment
Open

SplitInHalf is expensive, should use ropes #40

zcorpan opened this issue Jan 5, 2017 · 1 comment

Comments

@zcorpan
Copy link
Member

zcorpan commented Jan 5, 2017

See #39 (comment)

@zcorpan
Copy link
Member Author

zcorpan commented Jan 5, 2017

With #39 and with this diff to whatwg/html-build:

diff --git a/build.sh b/build.sh
index 24f30d6..7669382 100755
--- a/build.sh
+++ b/build.sh
@@ -369,7 +369,7 @@ function runWattsi {
   fi
 }
 
-runWattsi $HTML_TEMP/source-whatwg-complete $HTML_TEMP/wattsi-output
+time runWattsi $HTML_TEMP/source-whatwg-complete $HTML_TEMP/wattsi-output
 if [ "$WATTSI_RESULT" == "0" ]; then
     $QUIET || cat $HTML_TEMP/wattsi-output.txt | grep -v '^$' # trim blank lines
 else

I get, running ./build.sh -n a few times:

real	0m6.539s
user	0m5.740s
sys	0m0.566s

real	0m6.317s
user	0m5.652s
sys	0m0.513s

real	0m6.198s
user	0m5.619s
sys	0m0.492s

and then with current master (i.e. without #39):

real	0m6.210s
user	0m5.618s
sys	0m0.504s

real	0m6.296s
user	0m5.677s
sys	0m0.519s

real	0m6.357s
user	0m5.679s
sys	0m0.534s

Seems like it did not regress noticeably at least.

With the following diff on #39:

diff --git a/src/wattsi.pas b/src/wattsi.pas
index 1ac317a..53d7148 100644
--- a/src/wattsi.pas
+++ b/src/wattsi.pas
@@ -2017,6 +2017,7 @@ begin
   Result := i > 0;
   if Result then
   begin
+    Inform('SplitInHalf: ' + Txt);
     Half1 := Copy(Txt, 1, i-1);
     Half2 := Copy(Txt, i+Length(Separator), Length(Txt));
   end;

I get 755 rows logged. But only 11 after removing duplicate lines. So an alternative optimization could be to cache the result maybe?

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

No branches or pull requests

1 participant