-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vmprofile: Extend Lua API and add test cases
Extend the "Lua C API" for vmprofile to support allocating multiple profiles and switching between them. This makes it easier to use. Previously the expectation was that this functionality would be implemented in Lua code using ljsyscall to allocate file-backed shared memory for profiles and then the FFI to switch between them. (This is still possible, too, and it works the same as it did before.) Added test coverage to the test suite.
- Loading branch information
Showing
6 changed files
with
113 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ bc +luajit>=2 | |
computations.lua | ||
trace +jit | ||
opt +jit | ||
raptorjit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vmprofile.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
local vmprofile = require("jit.vmprofile") | ||
|
||
do --- vmprofile start and stop | ||
vmprofile.start() | ||
vmprofile.stop() | ||
end | ||
|
||
|
||
do --- vmprofile multiple starts | ||
for i = 1, 1000 do vmprofile.start() end | ||
vmprofile.stop() | ||
end | ||
|
||
do --- vmprofile multiple profiles | ||
vmprofile.start() | ||
local a = vmprofile.open("a.vmprofile") | ||
local b = vmprofile.open("b.vmprofile") | ||
vmprofile.select(a) | ||
for i = 1, 1e8 do end | ||
vmprofile.select(b) | ||
for i = 1, 1e8 do end | ||
vmprofile.select(a) | ||
for i = 1, 1e8 do end | ||
vmprofile.stop() | ||
vmprofile.close(a) | ||
vmprofile.close(b) | ||
-- simple sanity check that the profiles have different contents. | ||
-- e.g. to make sure there was at least one sample taken somewhere. | ||
assert(io.open("a.vmprofile", "r"):read("*a") ~= | ||
io.open("b.vmprofile", "r"):read("*a"), | ||
"check that profiles have different contents") | ||
os.remove("a.vmprofile") | ||
os.remove("b.vmprofile") | ||
end |