Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProB 2 Jupyter Kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
ProB 2 Jupyter Kernel
Commits
74910332
Commit
74910332
authored
May 28, 2018
by
dgelessus
Browse files
Options
Downloads
Patches
Plain Diff
Add :time command
parent
5b74f2a9
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/prob2/jupyter/ProBKernel.java
+2
-0
2 additions, 0 deletions
src/main/java/de/prob2/jupyter/ProBKernel.java
src/main/java/de/prob2/jupyter/commands/TimeCommand.java
+38
-0
38 additions, 0 deletions
src/main/java/de/prob2/jupyter/commands/TimeCommand.java
with
40 additions
and
0 deletions
src/main/java/de/prob2/jupyter/ProBKernel.java
+
2
−
0
View file @
74910332
...
...
@@ -29,6 +29,7 @@ import de.prob2.jupyter.commands.LoadFileCommand;
import
de.prob2.jupyter.commands.NoSuchCommandException
;
import
de.prob2.jupyter.commands.PrefCommand
;
import
de.prob2.jupyter.commands.SolveCommand
;
import
de.prob2.jupyter.commands.TimeCommand
;
import
de.prob2.jupyter.commands.VersionCommand
;
import
io.github.spencerpark.jupyter.kernel.BaseKernel
;
...
...
@@ -71,6 +72,7 @@ public final class ProBKernel extends BaseKernel {
this
.
lineCommands
.
put
(
":constants"
,
injector
.
getInstance
(
ConstantsCommand
.
class
));
this
.
lineCommands
.
put
(
":initialise"
,
injector
.
getInstance
(
InitialiseCommand
.
class
));
this
.
lineCommands
.
put
(
":init"
,
injector
.
getInstance
(
InitialiseCommand
.
class
));
this
.
lineCommands
.
put
(
":time"
,
injector
.
getInstance
(
TimeCommand
.
class
));
this
.
lineCommands
.
put
(
":groovy"
,
injector
.
getInstance
(
GroovyCommand
.
class
));
this
.
cellCommands
=
new
HashMap
<>();
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/prob2/jupyter/commands/TimeCommand.java
0 → 100644
+
38
−
0
View file @
74910332
package
de.prob2.jupyter.commands
;
import
com.google.inject.Inject
;
import
de.prob2.jupyter.ProBKernel
;
import
io.github.spencerpark.jupyter.messages.DisplayData
;
import
org.jetbrains.annotations.NotNull
;
public
final
class
TimeCommand
implements
LineCommand
{
private
static
final
long
NANOSECONDS_PER_SECOND
=
1000000000L
;
@Inject
private
TimeCommand
()
{
super
();
}
@Override
public
@NotNull
String
getSyntax
()
{
return
":time COMMAND [ARGS ...]"
;
}
@Override
public
@NotNull
String
getShortHelp
()
{
return
"Execute the given command and measure how long it takes to execute."
;
}
@Override
public
@NotNull
DisplayData
run
(
final
@NotNull
ProBKernel
kernel
,
final
@NotNull
String
argString
)
{
final
long
startTime
=
System
.
nanoTime
();
final
DisplayData
result
=
kernel
.
eval
(
argString
);
final
long
stopTime
=
System
.
nanoTime
();
final
long
diff
=
stopTime
-
startTime
;
System
.
out
.
printf
(
"Execution time: %d.%09d seconds%n"
,
diff
/
NANOSECONDS_PER_SECOND
,
diff
%
NANOSECONDS_PER_SECOND
);
return
result
;
}
}
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