{"id":16021713,"url":"https://github.com/davidanthoff/profilevega.jl","last_synced_at":"2025-04-05T03:43:31.098Z","repository":{"id":52247132,"uuid":"235684064","full_name":"davidanthoff/ProfileVega.jl","owner":"davidanthoff","description":"Vega-lite front end for the Julia profiler","archived":false,"fork":false,"pushed_at":"2023-05-10T18:24:46.000Z","size":99,"stargazers_count":28,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T12:46:44.909Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidanthoff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-22T22:56:14.000Z","updated_at":"2024-04-22T12:57:57.000Z","dependencies_parsed_at":"2024-10-30T18:36:45.458Z","dependency_job_id":null,"html_url":"https://github.com/davidanthoff/ProfileVega.jl","commit_stats":{"total_commits":37,"total_committers":6,"mean_commits":6.166666666666667,"dds":0.5135135135135135,"last_synced_commit":"baa6e733541f164b66b4b18e86f915dbbf93ff7a"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidanthoff%2FProfileVega.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidanthoff%2FProfileVega.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidanthoff%2FProfileVega.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidanthoff%2FProfileVega.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidanthoff","download_url":"https://codeload.github.com/davidanthoff/ProfileVega.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284918,"owners_count":20913691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T18:05:20.332Z","updated_at":"2025-04-05T03:43:31.078Z","avatar_url":"https://github.com/davidanthoff.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ProfileVega\n\n[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)\n![](https://github.com/davidanthoff/ProfileVega.jl/workflows/Run%20CI%20on%20master/badge.svg)\n[![codecov](https://codecov.io/gh/davidanthoff/ProfileVega.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/davidanthoff/ProfileVega.jl)\n\n\n## Overview\n\nProfileVega allows you to export profiling data as a\n[VegaLite.jl](https://github.com/queryverse/VegaLite.jl) figure. These\nfigures can be displayed in Jupyter/IJulia notebooks, or any other\nfigure display. It is essentially just an \"export\" package built on top of\n[FlameGraphs](https://github.com/timholy/FlameGraphs.jl).\n\nAn alternative visualization package is the GTK-based\n[ProfileView](https://github.com/timholy/ProfileView.jl).\n\nAmong the Julia packages, [ProfileView](https://github.com/timholy/ProfileView.jl)\ncurrently has the most comprehensive tutorial on how to interpret a flame graph.\n\n## Usage\n\n### Usage in Jupyter\n\n```julia\nusing ProfileVega\n@profview f(args...)\n```\n\nwhere `f(args...)` is the operation you want to profile.\n`@profview f(args...)` is just shorthand for\n\n```julia\nProfile.clear()\n@profile f(args...)\nProfileVega.view()\n```\n\nIf you've already collected profiling data with `@profile`, you can just call `ProfileVega.view()` directly.\n\nThe following screenshot illustrates Jupyter usage on a demonstration function `profile_test`:\n\n![profview](images/jupyter.png)\n\nYou can hover over individual blocks in the flame graph to get more detailed information.\n\nYou can pan the picture via drag and drop, and zoom via your mouse wheel.\n\nYou can adjust the size of the picture by passing `width` and `height` arguments\n\n```julia\n@profview f(args...) width = 800 height = 600\n\n# or alternatively\nProfile.clear()\n@profile f(args...)\nProfileVega.view(width = 800, height = 600)\n```\n\nSize parameters can also be set globally\n\n```julia\nProfileVega.set_default_size(800, 600)\n```\n\n### Exporting figures\n\nEven if you don't use Jupyter, you might want to export a flame graph as\na file as a convenient way to share the results with others. You can export\nflame graphs created with this package as PNG, SVG, PDF, vega or vega-lite\nfiles.\n\nHere's a demonstration:\n\n```julia\nfunction profile_test(n)\n    for i = 1:n\n        A = randn(100,100,20)\n        m = maximum(A)\n        Am = mapslices(sum, A; dims=2)\n        B = A[:,:,5]\n        Bsort = mapslices(sort, B; dims=1)\n        b = rand(100)\n        C = B.*b\n    end\nend\n\nprofile_test(1)   # run once to compile\n\nusing Profile, ProfileVega\nProfile.clear()\n@profile profile_test(10);\n\n# Save a graph that looks like the Jupyter example above\nProfileVega.view() |\u003e save(\"prof.svg\")\n```\n\n### Differential Flame Graphs\nDifferential flame graphs based on [Brendan Gregg](http://www.brendangregg.com/blog/2014-11-09/differential-flame-graphs.html) blog post and is a useful tool for comparison code before and after changes. It works like this\n\n* Take `baseline` stack profile.\n* Take `target` stack profile.\n* Generate a flame graph using target. (This sets the width of all frames using target profile)\n* Colorize the flame graph using the \"target - baseline\" delta. If a frame appeared more times in 2, it is red, less times, it is blue. The saturation is relative to the delta.\n\nThe intent is for use with before \u0026 after profiles, such as for non-regression testing or benchmarking code changes.\n\nHere is a demonstration:\n\n```julia\nfunction f1(n)\n    res = 0\n    for _ in 1:n\n        res += sum(rand(10_000))\n    end\n\n    for _ in 1:n\n        res -= sum(rand(10_000))\n    end\n    res\nend\n\nfunction f2(n)\n    res = 0\n    for _ in 1:n\n        res += sum(rand(20_000))\n    end\n\n    for _ in 1:n\n        A = randn(10, 10, 10)\n        res += maximum(A)\n    end\n\n    for _ in 1:n\n        res -= sum(rand(5_000))\n    end\n    res\nend\n\nf1(1) # run once to compile\nf2(1) # run once to compile\n\nusing ProfileVega\nbaseline = @profbase f1(10000);\n@profdiffview baseline f2(10000)\n```\n\nResults are shown on the following screenshot\n\n![profdiffview](images/diffflame.png)\n\nAs it can be seen generally it took longer to execute function `f2`. Most of this increased time is due to\nthe first `sum(rand(20_000))` cycle as expected, on the other hand second cycle `sum(rand(5_000))` took less\ntime to execute and therefore shown in blue. In the middle between these two cycles new node appeared which corresponds\nto the second cycle. Since there is nothing to compare to it is shown in gray.\n\nSometimes it is useful to compare baseline graph versus new benchmarks. ONe can use `negate` keyword for that\n\n```julia\n@profdiffview baseline f2(10000) negate = true\n```\n\nwith the following result\n\n![profdiffview](images/diffflame_negate.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidanthoff%2Fprofilevega.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidanthoff%2Fprofilevega.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidanthoff%2Fprofilevega.jl/lists"}