Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CS-206 Demos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sankalp Gambhir
CS-206 Demos
Commits
81d408ac
Unverified
Commit
81d408ac
authored
2 years ago
by
Hamza Remmal
Browse files
Options
Downloads
Patches
Plain Diff
Add Collection Conversion example from lecture 3
parent
3523f4b6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/lecture3/02_Conversion.scala
+38
-0
38 additions, 0 deletions
src/main/scala/lecture3/02_Conversion.scala
with
38 additions
and
0 deletions
src/main/scala/lecture3/02_Conversion.scala
0 → 100644
+
38
−
0
View file @
81d408ac
package
lecture3
import
scala.collection._
import
scala.collection.parallel.CollectionConverters.IterableIsParallelizable
import
org.scalameter._
object
Conversion
:
val
standardConfig
=
config
(
Key
.
exec
.
minWarmupRuns
:=
10
,
Key
.
exec
.
maxWarmupRuns
:=
20
,
Key
.
exec
.
benchRuns
:=
20
,
Key
.
verbose
:=
false
)
withWarmer
new
Warmer
.
Default
val
memConfig
=
config
(
Key
.
exec
.
minWarmupRuns
:=
0
,
Key
.
exec
.
maxWarmupRuns
:=
0
,
Key
.
exec
.
benchRuns
:=
10
,
Key
.
verbose
:=
true
)
withWarmer
Warmer
.
Zero
val
vector
=
Vector
.
fill
(
10000000
)(
""
)
val
list
=
vector
.
toList
@main
def
run
=
val
listTime
=
standardConfig
measure
{
list
.
par
}
println
(
s
"list conversion time $listTime"
)
val
vectorTime
=
standardConfig
measure
{
vector
.
par
}
println
(
s
"vector conversion time $vectorTime"
)
println
(
s
"difference : ${listTime.value / vectorTime.value}"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment