Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
zaide
BakuJS
Commits
60517c8a
Commit
60517c8a
authored
Jan 24, 2016
by
Zéfling
🎨
Browse files
Changement de méthode de calcul du temps des tests
parent
f4ab6981
Changes
1
Hide whitespace changes
Inline
Side-by-side
test.js
View file @
60517c8a
...
...
@@ -3,35 +3,38 @@ Test.title = function (title) {
var
b
=
document
.
createElement
(
"
h2
"
);
b
.
textContent
=
title
;
document
.
body
.
appendChild
(
b
);
this
.
time
=
performance
.
now
()
;
};
Test
.
equals
=
function
(
test
,
equals
,
message
)
{
var
result
,
ok
,
diff
=
performance
.
now
()
-
this
.
time
,
b
=
document
.
createElement
(
"
div
"
);
var
result
,
ok
,
time1
,
time
2
,
b
=
document
.
createElement
(
"
div
"
);
try
{
time1
=
performance
.
now
();
result
=
eval
(
test
);
time2
=
performance
.
now
();
ok
=
result
==
equals
;
}
catch
(
e
)
{
ok
=
false
;
}
b
.
classList
.
add
(
ok
?
'
ok
'
:
'
ko
'
);
b
.
title
=
message
+
(
ok
?
'
#ok
'
:
'
#ko : "
'
+
result
+
'
" != "
'
+
equals
+
'
"
'
)
+
'
(
'
+
(
Math
.
round
(
diff
*
10000
)
/
10000
)
+
'
ms)
'
;
b
.
title
=
message
+
(
ok
?
'
#ok
'
:
'
#ko : "
'
+
result
+
'
" != "
'
+
equals
+
'
"
'
)
+
'
(
'
+
(
Math
.
round
(
(
time2
-
time1
)
*
10000
)
/
10000
)
.
formatByPattern
(
'
#,###.000
'
)
+
'
ms)
'
;
document
.
body
.
appendChild
(
b
);
this
.
time
=
performance
.
now
();
};
Test
.
error
=
function
(
test
)
{
var
ok
=
false
,
message
=
'
valide ?
'
,
diff
=
performance
.
now
()
-
this
.
time
,
b
=
document
.
createElement
(
"
div
"
);
try
{
time1
=
performance
.
now
();
result
=
eval
(
test
);
time2
=
performance
.
now
();
}
catch
(
e
)
{
time2
=
performance
.
now
();
ok
=
true
;
message
=
e
;
}
b
.
classList
.
add
(
ok
?
'
ok
'
:
'
ko
'
);
b
.
title
=
test
+
(
ok
?
'
#ko :
'
+
message
:
'
#ok : "
'
+
result
+
'
"
'
)
+
'
(
'
+
(
Math
.
round
(
diff
*
10000
)
/
10000
)
+
'
ms)
'
;
b
.
title
=
test
+
(
ok
?
'
#ko :
'
+
message
:
'
#ok : "
'
+
result
+
'
"
'
)
+
'
(
'
+
(
Math
.
round
(
(
time2
-
time1
)
*
10000
)
/
10000
)
.
formatByPattern
(
'
#,###.000
'
)
+
'
ms)
'
;
document
.
body
.
appendChild
(
b
);
this
.
time
=
performance
.
now
();
};
// ----------------------------------------------------------------------------------
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment