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

Make createClass 10-15% faster on complex specs #5550

Merged
merged 2 commits into from Dec 14, 2015

Conversation

Projects
None yet
4 participants
@sophiebits
Copy link
Collaborator

commented Nov 26, 2015

.

sophiebits added some commits Nov 26, 2015

Add createClass stress test
Running this is left as an exercise for the reader, since my measure.py isn't designed for this at present. But something like this might work:

```diff
diff --git a/scripts/bench/measure.py b/scripts/bench/measure.py
index 4cedf47..627ec97 100755
--- a/scripts/bench/measure.py
+++ b/scripts/bench/measure.py
@@ -79,15 +79,12 @@ def _measure_ssr_ms(engine, react_path, bench_name, bench_path, measure_warm):
             if (typeof React !== 'object') throw new Error('React not laoded');
             report('factory_ms', END - START);

-            globalEval(readFile(ENV.bench_path));
-            if (typeof Benchmark !== 'function') {
-              throw new Error('benchmark not loaded');
-            }
+            globalEval("bm = (function(){" + readFile("bench-createclass-madman.js") + "})");
+            bm();
             var START = now();
-            var html = React.renderToString(React.createElement(Benchmark));
-            html.charCodeAt(0);  // flatten ropes
+            bm();
             var END = now();
-            report('ssr_' + ENV.bench_name + '_cold_ms', END - START);
+            report('cc_' + ENV.bench_name + '_cold_ms', END - START);

             var warmup = ENV.measure_warm ? 80 : 0;
             var trials = ENV.measure_warm ? 40 : 0;
@@ -119,7 +116,7 @@ def _main():
         return 1
     react_path = sys.argv[1]

-    trials = 30
+    trials = 60
     sys.stderr.write("Measuring SSR for PE benchmark (%d trials)\n" % trials)
     for i in range(trials):
         for engine in [
@@ -132,7 +129,7 @@ def _main():
         sys.stderr.flush()
     sys.stderr.write("\n")

-    trials = 3
+    trials = 0#3
     sys.stderr.write("Measuring SSR for PE with warm JIT (%d slow trials)\n" % trials)
     for i in range(trials):
         for engine in [
```
@mridgway

This comment has been minimized.

Copy link
Contributor

commented Nov 26, 2015

I like this. 👍

@sophiebits

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 26, 2015

Since createClass doesn't take that much time, the absolute gains here aren't great – maybe a few ms for a typical app with a hundred components – but this should still be an improvement.

@sebmarkbage

This comment has been minimized.

Copy link
Member

commented Dec 14, 2015

k

sophiebits added a commit that referenced this pull request Dec 14, 2015

Merge pull request #5550 from spicyj/cc-speed
Make createClass 10-15% faster on complex specs

@sophiebits sophiebits merged commit 3997164 into facebook:master Dec 14, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@renovate renovate bot referenced this pull request Feb 2, 2018

Open

Update dependency react to v0.14.9 #29

0 of 1 task complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.