-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
11
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 1 commit
Commits
Show all changes
11 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 5d5b565
Merge branch 'main' into feat/benchmarker
cieplypolar 918547f
review changes
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
Prev
Previous commit
review changes
- Loading branch information
commit 918547f0fca450540debcda1f64fe76009a0b829
Some comments aren't visible on the classic Files Changed page.
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
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 | ||||
|---|---|---|---|---|---|---|
| @@ -1,12 +1,15 @@ | ||||||
| import { ChevronLeft, ChevronRight } from 'lucide-react'; | ||||||
| import { useCallback, useEffect, useMemo, useState } from 'react'; | ||||||
| import { useCallback, useEffect, 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', | ||||||
| ]; | ||||||
| const slideCount = plots.length; | ||||||
| const extendedPlots = [plots[slideCount - 1], ...plots, plots[0]]; | ||||||
| const extendedSlideCount = extendedPlots.length; | ||||||
|
|
||||||
| function PlotSlide({ url }: { url: string }) { | ||||||
| return ( | ||||||
|
|
@@ -25,12 +28,6 @@ const buttonUtilityClasses = | |||||
| 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); | ||||||
|
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.
Suggested change
I would go for this - isTransitioning does not need to cause re-renders and it will simplify transition handling |
||||||
|
|
||||||
|
|
@@ -41,21 +38,19 @@ export default function PlotGallery() { | |||||
| }, []); | ||||||
|
|
||||||
| 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(slideCount); | ||||||
| } else if (index === extendedSlideCount - 1) { | ||||||
| setCurrentIndex(1); | ||||||
| } | ||||||
| }, [extendedPlots]); | ||||||
| }, []); | ||||||
|
|
||||||
| const goToSlide = useCallback((index: number, isTransitioning: boolean) => { | ||||||
| if (isTransitioning) return; | ||||||
|
|
@@ -64,8 +59,8 @@ export default function PlotGallery() { | |||||
| }, []); | ||||||
|
|
||||||
| const getActualIndex = (): number => { | ||||||
| if (currentIndex === 0) return plots.length - 1; | ||||||
| if (currentIndex === extendedPlots.length - 1) return 0; | ||||||
| if (currentIndex === 0) return slideCount - 1; | ||||||
| if (currentIndex === extendedSlideCount - 1) return 0; | ||||||
| return currentIndex - 1; | ||||||
| }; | ||||||
|
|
||||||
|
|
@@ -99,7 +94,7 @@ export default function PlotGallery() { | |||||
|
|
||||||
| <div | ||||||
| className={`flex h-full w-full transition-transform duration-200 ease-in-out ${ | ||||||
| isTransitioning ? '' : 'transition-none' // this is necessary for smooth ending | ||||||
| isTransitioning ? '' : 'transition-none' // this is necessary for smooth wrapping | ||||||
| }`} | ||||||
| style={{ transform: `translateX(-${currentIndex * 100}%)` }} | ||||||
| onTransitionEnd={() => handleTransitionEnd(currentIndex)} | ||||||
|
|
||||||
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.
This is a little over-engineered but since it's for dev I don't really mind it (all the comments are just general feedback for learning purposes).
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.
I appreciate the feedback. I deleted
useMemo, but I can't changeisTransitioningtouseRef.isTransitioningstate plays a crucial role in smooth carousel wrap when we transition from the last plot -> to the first plot (and first -> last).isTransitioningto false, and change the index to real plot (not the guarding one)