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

What about remove Function creation? #81

Open
nazar-pc opened this issue Jul 7, 2014 · 3 comments
Open

What about remove Function creation? #81

nazar-pc opened this issue Jul 7, 2014 · 3 comments

Comments

@nazar-pc
Copy link

nazar-pc commented Jul 7, 2014

I'm talking about code like this:

this.resampler = Function("buffer", toCompile);

I'm using this awesome library in Firefox OS Application (Open Web Apps), and it doesn't support such things because of Content Security Policy (CSP).

It is possible to rewrite this code without such function declaration. I can do that, and send pull request, or if you have time - I can wait few days.

What do you think about this?

@devongovett
Copy link
Member

Hmm, that's annoying. The only code that uses that is the resampler, which was imported from a 3rd party. It is definitely possible to rewrite that code so it is a normal function instead of a generated one. The point of doing it the way it is currently is for performance reasons since the generated function contains no loops and many values can be hardcoded rather than variables since everything is inlined when the function is generated. It would be interesting to see a performance comparison between that and a normal function version. If it's impossible to use generated functions like that, I guess you'd have to create a normal function version instead. If you do that, I'd be interested to see the results!

@nazar-pc
Copy link
Author

nazar-pc commented Jul 7, 2014

Performance is a good reason, but comparing to inability to use library when re-sampling is needed, I'd prefer slower but working solution.
I'll try to make normal function, but have no idea how to test performance because I'm not familiar with code base and this is not my sphere of competence.
Can you make performance comparison of two versions if they'll exist?

@nazar-pc
Copy link
Author

nazar-pc commented Jul 7, 2014

Here is it.
Works pretty good under Firefox OS simulator.
But I see two ways of further optimizations:

  1. As majority of tracks have only 2 (rarely 1) channel - we can create separate functions specifically for these cases, and they'll work even faster than generated ones
  2. Since resampling functions contain only simple mathematic calculations - it is possible rewrite functions manually using asm.js, that will give even more performance boost

If you are interesting in this - I can do that.

Waiting for performance tests from you.

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

No branches or pull requests

2 participants