Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
LARA
inox
Commits
80315682
Commit
80315682
authored
13 years ago
by
Ali Sinan Köksal
Browse files
Options
Downloads
Patches
Plain Diff
timer in listmethods example
parent
2a0f9314
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cp-demo/executing-specs/ListMethods.scala
+19
-0
19 additions, 0 deletions
cp-demo/executing-specs/ListMethods.scala
with
19 additions
and
0 deletions
cp-demo/executing-specs/ListMethods.scala
+
19
−
0
View file @
80315682
...
...
@@ -78,9 +78,13 @@ object ListMethods {
println
(
lists
.
mkString
(
"\n"
))
// println("Here is its last element: " + last(l))
Timer
.
go
val
lastElems
=
lists
.
map
(
l
=>
last
(
l
))
val
measured
=
Timer
.
stop
println
(
"last elements:"
)
println
(
lastElems
)
println
(
"measured:"
+
measured
)
println
(
"average :"
+
(
measured
/
nbLists
))
// val added = lists.map(appendElem(_, 42))
// println("Here are those lists with 42 added to them:")
...
...
@@ -90,3 +94,18 @@ object ListMethods {
// println("Here is the previous list, this time sorted: " + sorted)
}
}
object
Timer
{
var
start
:
Long
=
0L
var
end
:
Long
=
0L
def
go
=
{
start
=
System
.
currentTimeMillis
}
def
stop
=
{
end
=
System
.
currentTimeMillis
val
measured
=
(
end
-
start
)
/
1000.0
println
(
"Measured time: "
+
measured
+
" s"
)
measured
}
}
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