Skip to content

Performance optimizations for dynamic function execution. #106

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

Merged

Conversation

benjchristensen
Copy link
Member

  • memoize dynamic function constructions so executions are statically typed after a single dynamic lookup instead of dynamic on every execution

#104

- memoize dynamic function constructions so executions are statically typed after a single dynamic lookup instead of dynamic on every execution
@benjchristensen
Copy link
Member Author

Test case:

    public void runCompositionTest(Integer[] values) {
        System.out.println("runCompositionTest");

        final AtomicInteger onNextSum = new AtomicInteger(0);
        final long start = System.nanoTime();

        MathFunction m = new MathFunction();
        // 50 levels of composition (same function so that's not the cost)
        Observable.from(values)
                .map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m)
                .map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m)
                .map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m)
                .map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m)
                .map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m).map(m)
                .subscribe(new TestObserver(onNextSum, start));
    }

Before this commit:

Sum: 710082754 Time: 437.936ms

After this commit:

Sum: 710082754 Time: 60.605ms

benjchristensen added a commit that referenced this pull request Jan 22, 2013
Performance optimizations for dynamic function execution.

#104
@benjchristensen benjchristensen merged commit 48cd6cc into ReactiveX:master Jan 22, 2013
rickbw pushed a commit to rickbw/RxJava that referenced this pull request Jan 9, 2014
…ation

Performance optimizations for dynamic function execution.

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

Successfully merging this pull request may close these issues.

1 participant