-
Notifications
You must be signed in to change notification settings - Fork 261
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
Running code in gophernotes is much slower than using go run #250
Comments
Having said that - It may be helpful to share some specific code, since there could possibly be ways to change it to be more performant in the gophernotes environment |
Go toolchain and standard library do not support (and actually makes really hard to) JIT-compile code at runtime and execute it.
For these reasons, almost all Go interpreters use reflection to manipulate Go data structures, and the interpreted code is executed either as closures, as a bytecode interpreter, or (at worst) AST tree walking. All these techniques have an overhead, and from some of my (old) benchmarks gophernotes and gomacro are among the fastest Go interpreters available, averaging to 10-100 times slower than compiled Go. As @mccolljr pointed out, the speed depends a lot from the code you run: Note: there is an interpreter gijit that compiles Go source code to Lua. It's fast but has to to a lot of convolutions to manipulate Go data structures. |
Update: imported packages are automatically compiled by gophernotes/gomacro using Go toolchain, and loaded as plugins (this works on Linux and Mac OS X only - unluckily on Windows the procedure is more convoluted). So if there's a particular piece of code that your really need to be fast, you can for example: import "github.com/my/package/full/path" or even import it from a local filesystem path (useful in case the package is not published): import "/my/package/absolute/path"
import "./my/package/relative/path"
import "../my/package/relative/path" then use your favorite package from gophernotes, and it will be compiled to native code. |
thanks for answer
thanks for answer |
Is there any solution
The text was updated successfully, but these errors were encountered: