Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6e74ebb

Browse files
committed
show format and render time
1 parent95c7159 commit6e74ebb

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

‎index.html‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ <h2>Input: JSON</h2>
7171
<buttonid="convert">Convert</button>
7272
</div>
7373

74+
<h2>Time</h2>
75+
76+
<p>Format Time:<spanid="format-time"></span></p>
77+
<p>Render Time:<spanid="render-time"></span></p>
78+
7479
<h2>Output: HTML</h2>
7580

7681
<divid="output">

‎js/demo.js‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,45 @@ require(["../src/json.human"], function (JsonHuman) {
99
vartextarea=document.getElementById("input"),
1010
output=document.getElementById("output"),
1111
raw=document.getElementById("output-raw"),
12+
formatTime=document.getElementById("format-time"),
13+
renderTime=document.getElementById("render-time"),
1214
button=document.getElementById("convert"),
1315
editor=CodeMirror.fromTextArea(textarea,{
1416
mode:"application/json",
1517
json:true
1618
});
1719

1820
functionconvert(input,output){
19-
varnode=JsonHuman.format(input);
21+
varnode,t1,t2,t3,formatTimeMs,renderTimeMs;
22+
t1=Date.now();
23+
node=JsonHuman.format(input);
24+
t2=Date.now();
2025

2126
output.innerHTML="";
2227
output.appendChild(node);
28+
t3=Date.now();
2329
raw.textContent=output.innerHTML;
30+
31+
32+
formatTimeMs=t2-t1;
33+
renderTimeMs=t3-t2;
34+
35+
formatTime.innerHTML=""+formatTimeMs+"ms";
36+
renderTime.innerHTML=""+renderTimeMs+"ms";
37+
}
38+
39+
function_doConvert(){
40+
varjson=JSON.parse(editor.getValue());
41+
returnconvert(json,output);
2442
}
2543

2644
functiondoConvert(){
27-
varjson;
2845
try{
29-
json=JSON.parse(editor.getValue());
46+
return_doConvert();
3047
}catch(error){
3148
alert("Error parsing json:\n"+error.stack);
3249
return;
3350
}
34-
35-
convert(json,output);
3651
}
3752

3853
button.addEventListener("click",doConvert);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp