-
-
Notifications
You must be signed in to change notification settings - Fork 36
feat: Resolve benchmark github action #1886
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
Open
cieplypolar
wants to merge
9
commits into
main
Choose a base branch
from
feat/benchmarker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
79a5061
benchmark github action
cieplypolar f71862a
deno
cieplypolar 25f021a
Merge branch 'main' into feat/benchmarker
cieplypolar 8433ec0
Merge branch 'main' into feat/benchmarker
cieplypolar 1326e7b
plot gallery component with arrows control
cieplypolar d87db81
dots at the bottom
cieplypolar daabfcd
react <3
cieplypolar 1bd8e14
no scroll on mobile
cieplypolar 5a0293a
bye refs
cieplypolar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,91 @@ | ||
| name: Measure resolve duration | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| BENCHMARK_REPO: software-mansion-labs/typegpu-benchmarker | ||
|
|
||
| jobs: | ||
| measure: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Clone benchmarking repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| repository: ${{ env.BENCHMARK_REPO }} | ||
| ref: main | ||
| token: ${{ secrets.BENCHMARKER_REPO_ACCESS_TOKEN }} | ||
|
|
||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| run_install: false | ||
|
|
||
| - name: Install Node.js 22.x | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22.x | ||
| cache: 'pnpm' | ||
|
|
||
| - name: Install deps | ||
| run: | | ||
| pnpm install --frozen-lockfile | ||
| - name: Install Deno | ||
| uses: denoland/setup-deno@v2 | ||
| with: | ||
| deno-version: v2.x | ||
|
|
||
| - name: Run benchmarks | ||
| run: | | ||
| pnpm run measure | ||
| - name: Save benchmark results across the jobs | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: data | ||
| path: benchmarks | ||
| plot: | ||
| runs-on: ubuntu-latest | ||
| needs: measure | ||
|
|
||
| steps: | ||
| - name: Clone benchmarking repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| repository: ${{ env.BENCHMARK_REPO }} | ||
| ref: main | ||
| token: ${{ secrets.BENCHMARKER_REPO_ACCESS_TOKEN }} | ||
|
|
||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| run_install: false | ||
|
|
||
| - name: Download benchmark data | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: data | ||
| path: benchmarks | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '>=3.11' | ||
|
|
||
| - name: Create venv | ||
| run: | | ||
| python3 -m venv .venv | ||
| - name: Plot | ||
| shell: bash | ||
| run: | | ||
| . .venv/bin/activate | ||
| pip install -r requirements.txt | ||
| pnpm run plot | ||
| - name: Commit and push results and plot | ||
| run: | | ||
| git config user.name "github-actions" | ||
| git config user.email "[email protected]" | ||
| git add . | ||
| git commit -m "Automated benchmark update" || echo "No changes" | ||
| git push origin main |
This file contains hidden or 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
128 changes: 128 additions & 0 deletions
128
apps/typegpu-docs/src/components/resolve/PlotGallery.tsx
This file contains hidden or 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,128 @@ | ||
| import { ChevronLeft, ChevronRight } from 'lucide-react'; | ||
| import { useCallback, useEffect, useMemo, useState } from 'react'; | ||
|
|
||
| const plots = [ | ||
| 'https://raw.githubusercontent.com/software-mansion-labs/typegpu-benchmarker/main/plots/combined-resolveDuration-full.png', | ||
| 'https://raw.githubusercontent.com/software-mansion-labs/typegpu-benchmarker/main/plots/combined-resolveDuration-full-log.png', | ||
| 'https://raw.githubusercontent.com/software-mansion-labs/typegpu-benchmarker/main/plots/combined-resolveDuration-latest5.png', | ||
| 'https://raw.githubusercontent.com/software-mansion-labs/typegpu-benchmarker/main/plots/combined-resolveDuration-under10k.png', | ||
| ]; | ||
|
|
||
| function PlotSlide({ url }: { url: string }) { | ||
| return ( | ||
| <div className='flex h-[60vh] max-h-[50vw] w-full flex-shrink-0 justify-center'> | ||
| <img | ||
| className='h-full rounded-2xl object-contain' | ||
| src={`${url}?t=${Date.now()}`} // TODO: proper versioning ;) | ||
| alt={`${new URL(url).pathname.split('/').pop()}`} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| const buttonUtilityClasses = | ||
| '-translate-y-1/2 absolute top-1/2 rounded-full border border-gray-700 bg-gray-800 p-4 text-gray-150 transition-all duration-300 ease-in-out hover:bg-gray-700 hover:text-white active:bg-gray-500 active:text-white z-1'; | ||
| const chevronUtilityClasses = 'w-4 h-4 sm:w-8 sm:h-8'; | ||
|
|
||
| export default function PlotGallery() { | ||
| // this is for infinite effect | ||
| const extendedPlots = useMemo( | ||
| () => [plots[plots.length - 1], ...plots, plots[0]], | ||
| [], | ||
| ); | ||
|
|
||
| const [currentIndex, setCurrentIndex] = useState(1); | ||
| const [isTransitioning, setIsTransitioning] = useState(false); | ||
|
|
||
| const nextSlide = useCallback((isTransitioning: boolean) => { | ||
| if (isTransitioning) return; | ||
| setIsTransitioning(true); | ||
| setCurrentIndex((prev) => prev + 1); // to avoid deps | ||
| }, []); | ||
|
|
||
| const prevSlide = useCallback((isTransitioning: boolean) => { | ||
| console.log(isTransitioning); | ||
| if (isTransitioning) return; | ||
| setIsTransitioning(true); | ||
| setCurrentIndex((prev) => prev - 1); | ||
| }, []); | ||
|
|
||
| const handleTransitionEnd = useCallback((index: number) => { | ||
| setIsTransitioning(false); | ||
|
|
||
| if (index === 0) { | ||
| setCurrentIndex(plots.length); | ||
| } else if (index === extendedPlots.length - 1) { | ||
| setCurrentIndex(1); | ||
| } | ||
| }, [extendedPlots]); | ||
|
|
||
| const goToSlide = useCallback((index: number, isTransitioning: boolean) => { | ||
| if (isTransitioning) return; | ||
| setIsTransitioning(true); | ||
| setCurrentIndex(index + 1); | ||
| }, []); | ||
|
|
||
| const getActualIndex = (): number => { | ||
| if (currentIndex === 0) return plots.length - 1; | ||
| if (currentIndex === extendedPlots.length - 1) return 0; | ||
| return currentIndex - 1; | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| // TODO: add touch handling | ||
| const handleKeyDown = (event: KeyboardEvent) => { | ||
| if (event.key === 'ArrowLeft') prevSlide(isTransitioning); | ||
| if (event.key === 'ArrowRight') nextSlide(isTransitioning); | ||
| }; | ||
| window.addEventListener('keydown', handleKeyDown); | ||
| return () => window.removeEventListener('keydown', handleKeyDown); | ||
| }, [prevSlide, nextSlide, isTransitioning]); | ||
|
|
||
| return ( | ||
| <div className='relative flex-grow overflow-hidden'> | ||
| <button | ||
| className={`left-4 ${buttonUtilityClasses}`} | ||
| type='button' | ||
| onClick={() => prevSlide(isTransitioning)} | ||
| > | ||
| <ChevronLeft className={chevronUtilityClasses} /> | ||
| </button> | ||
|
|
||
| <button | ||
| className={`right-4 ${buttonUtilityClasses}`} | ||
| type='button' | ||
| onClick={() => nextSlide(isTransitioning)} | ||
| > | ||
| <ChevronRight className={chevronUtilityClasses} /> | ||
| </button> | ||
|
|
||
| <div | ||
| className={`flex h-full w-full transition-transform duration-200 ease-in-out ${ | ||
| isTransitioning ? '' : 'transition-none' // this is necessary for smooth ending | ||
| }`} | ||
| style={{ transform: `translateX(-${currentIndex * 100}%)` }} | ||
| onTransitionEnd={() => handleTransitionEnd(currentIndex)} | ||
| > | ||
| {extendedPlots.map((url, index) => ( | ||
| <PlotSlide key={`slide-${index}-${url}`} url={url} /> | ||
| ))} | ||
| </div> | ||
|
|
||
| <div className='-translate-x-1/2 absolute bottom-17 left-1/2 flex space-x-3'> | ||
| {plots.map((url, index) => ( | ||
| <button | ||
| key={`dot-${index}-${url}`} | ||
| type='button' | ||
| onClick={() => goToSlide(index, isTransitioning)} | ||
| className={`h-4 w-4 rounded-full transition-all duration-200 ease-in-out ${ | ||
| index === getActualIndex() | ||
| ? 'scale-125 bg-gray-500' | ||
| : 'bg-gray-800 hover:bg-gray-700' | ||
| }`} | ||
| /> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that the page does not respond to the light theme, but /benchmark acts the same so we may ignore it (at least until the landing page rework) |
This file contains hidden or 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,19 @@ | ||
| --- | ||
| import { Image } from "astro:assets"; | ||
| import PageLayout from "../../layouts/PageLayout.astro"; | ||
| import PlotGallery from "../../components/resolve/PlotGallery.tsx"; | ||
| import TypeGPULogoDark from "../../assets/typegpu-logo-dark.svg"; | ||
| --- | ||
|
|
||
| <PageLayout title="TypeGPU functions resolve complexity | TypeGPU" theme="dark"> | ||
| <main class="h-[100dvh] flex flex-col"> | ||
| <h1 class="flex items-center justify-center"> | ||
| <a href="/TypeGPU"> | ||
| <Image src={TypeGPULogoDark} alt="TypeGPU Logo" class="w-40" /> | ||
| </a> | ||
| <p class="text-lg font-sans text-gray-300">— resolve complexity</p> | ||
| </h1> | ||
|
|
||
| <PlotGallery client:only="react" /> | ||
| </main> | ||
| </PageLayout> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need that?