Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chat33test
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lkx33
chat33test
Commits
014ce6dd
Commit
014ce6dd
authored
Apr 19, 2021
by
lkx33
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志格式改动,修改解析方式
parent
e467e5da
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
95 deletions
+55
-95
analyzer.py
analyzer.py
+15
-21
chart.py
chart.py
+2
-2
ChatError_2021-04-09T11_44_19+08_00.log
log/ChatError_2021-04-09T11_44_19+08_00.log
+0
-0
ChatReceive_2021-04-09T11_44_19+08_00.log
log/ChatReceive_2021-04-09T11_44_19+08_00.log
+0
-18
ChatSendReply_2021-04-09T11_44_19+08_00.log
log/ChatSendReply_2021-04-09T11_44_19+08_00.log
+0
-18
ChatSend_2021-04-09T11_44_19+08_00.log
log/ChatSend_2021-04-09T11_44_19+08_00.log
+0
-18
reader.py
reader.py
+38
-18
No files found.
analyzer.py
View file @
014ce6dd
...
...
@@ -17,33 +17,27 @@ def formatData(sortType=0):
# 0为logId,1为发送时间,2为reply时间,3为接收时间,4reply延迟,5接收延迟
logData
=
[]
source
=
initData
()
for
line
in
source
:
logLine
=
[]
logID
=
line
[
0
]
sendTime
=
line
[
1
]
replyTime
=
line
[
2
]
receiveTime
=
line
[
3
]
for
i
in
source
:
# 格式化时间
time1
=
datetime
.
datetime
.
strptime
(
sendTime
,
"
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S.
%
f
%
z"
)
time2
=
datetime
.
datetime
.
strptime
(
replyTime
,
"
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S.
%
f
%
z"
)
time3
=
datetime
.
datetime
.
strptime
(
receiveTime
,
"
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S.
%
f
%
z"
)
#
time1 = datetime.datetime.strptime(
#
sendTime, "%Y-%m-%dT%H:%M:%S.%f%z")
#
time2 = datetime.datetime.strptime(
#
replyTime, "%Y-%m-%dT%H:%M:%S.%f%z")
#
time3 = datetime.datetime.strptime(
#
receiveTime, "%Y-%m-%dT%H:%M:%S.%f%z")
# 转换为时间戳
stamp1
=
time
.
mktime
(
time1
.
timetuple
())
*
1000
+
time1
.
microsecond
/
1000
stamp2
=
time
.
mktime
(
time2
.
timetuple
())
*
1000
+
time2
.
microsecond
/
1000
stamp3
=
time
.
mktime
(
time3
.
timetuple
())
*
1000
+
time3
.
microsecond
/
1000
#
stamp1 = time.mktime(time1.timetuple())*1000+time1.microsecond/1000
#
stamp2 = time.mktime(time2.timetuple())*1000+time2.microsecond/1000
#
stamp3 = time.mktime(time3.timetuple())*1000+time3.microsecond/1000
# 计算延迟
replyLag
=
stamp2
-
stamp1
msgLag
=
stamp3
-
stamp1
replyLag
=
i
[
'msgSendReplyTime'
]
-
i
[
'msgSendTime'
]
msgLag
=
i
[
'msgReceiveTime'
]
-
i
[
'msgSendTime'
]
log
Line
=
[
logID
,
stamp1
,
stamp2
,
stamp3
,
replyLag
,
msgLag
]
logData
.
append
(
logLine
)
# print(logData)
log
Data
.
append
([
i
[
'logId'
],
i
[
'msgSendTime'
],
i
[
'msgSendReplyTime'
],
i
[
'msgReceiveTime'
],
replyLag
,
msgLag
]
)
# print(sorted(logData, key=lambda x: x[3]))
logData
.
sort
(
key
=
lambda
x
:
x
[
sortType
])
return
logData
...
...
chart.py
View file @
014ce6dd
...
...
@@ -65,5 +65,5 @@ def chartByTime():
plt
.
show
()
chartByPercent
()
#
chartByTime()
#
chartByPercent()
chartByTime
()
log/ChatError_2021-04-09T11_44_19+08_00.log
deleted
100644 → 0
View file @
e467e5da
log/ChatReceive_2021-04-09T11_44_19+08_00.log
deleted
100644 → 0
View file @
e467e5da
113242168981721088 2021-04-09T11:43:57.002911+08:00 2021-04-09T11:43:57.082412+08:00
113242169422123008 2021-04-09T11:43:57.120087+08:00 2021-04-09T11:43:57.191507+08:00
113242173134082048 2021-04-09T11:43:58.004714+08:00 2021-04-09T11:43:58.058052+08:00
113242173649981440 2021-04-09T11:43:58.120769+08:00 2021-04-09T11:43:58.199444+08:00
113242177366134784 2021-04-09T11:43:59.005378+08:00 2021-04-09T11:43:59.05548+08:00
113242177856868352 2021-04-09T11:43:59.124919+08:00 2021-04-09T11:43:59.166122+08:00
113242168608428032 2021-04-09T11:43:56.921894+08:00 2021-04-09T11:43:56.994145+08:00
113242169489231872 2021-04-09T11:43:57.120364+08:00 2021-04-09T11:43:57.191537+08:00
113242172941144064 2021-04-09T11:43:57.927456+08:00 2021-04-09T11:43:58.033104+08:00
113242173717090304 2021-04-09T11:43:58.120806+08:00 2021-04-09T11:43:58.199444+08:00
113242177261277184 2021-04-09T11:43:58.931195+08:00 2021-04-09T11:43:59.055451+08:00
113242177915588608 2021-04-09T11:43:59.124973+08:00 2021-04-09T11:43:59.214147+08:00
113242168671342592 2021-04-09T11:43:56.922348+08:00 2021-04-09T11:43:56.994145+08:00
113242169032052736 2021-04-09T11:43:57.003009+08:00 2021-04-09T11:43:57.082492+08:00
113242173008252928 2021-04-09T11:43:57.927544+08:00 2021-04-09T11:43:58.033106+08:00
113242173268299776 2021-04-09T11:43:58.004756+08:00 2021-04-09T11:43:58.079105+08:00
113242177324191744 2021-04-09T11:43:58.931303+08:00 2021-04-09T11:43:59.055701+08:00
113242177424855040 2021-04-09T11:43:59.005552+08:00 2021-04-09T11:43:59.078238+08:00
log/ChatSendReply_2021-04-09T11_44_19+08_00.log
deleted
100644 → 0
View file @
e467e5da
113242168608428032 2021-04-09T11:43:56.994145+08:00
113242168671342592 2021-04-09T11:43:56.994173+08:00
113242172941144064 2021-04-09T11:43:58.005519+08:00
113242173008252928 2021-04-09T11:43:58.033101+08:00
113242177261277184 2021-04-09T11:43:59.024437+08:00
113242177324191744 2021-04-09T11:43:59.055448+08:00
113242168981721088 2021-04-09T11:43:57.082337+08:00
113242169032052736 2021-04-09T11:43:57.082359+08:00
113242173134082048 2021-04-09T11:43:58.058051+08:00
113242173268299776 2021-04-09T11:43:58.078982+08:00
113242177366134784 2021-04-09T11:43:59.055664+08:00
113242177424855040 2021-04-09T11:43:59.078214+08:00
113242169422123008 2021-04-09T11:43:57.191459+08:00
113242169489231872 2021-04-09T11:43:57.19149+08:00
113242173649981440 2021-04-09T11:43:58.199609+08:00
113242173717090304 2021-04-09T11:43:58.199717+08:00
113242177856868352 2021-04-09T11:43:59.166322+08:00
113242177915588608 2021-04-09T11:43:59.186449+08:00
log/ChatSend_2021-04-09T11_44_19+08_00.log
deleted
100644 → 0
View file @
e467e5da
2021-04-09T11:43:56.921894+08:00
2021-04-09T11:43:56.922348+08:00
2021-04-09T11:43:57.927456+08:00
2021-04-09T11:43:57.927544+08:00
2021-04-09T11:43:58.931195+08:00
2021-04-09T11:43:58.931303+08:00
2021-04-09T11:43:57.002911+08:00
2021-04-09T11:43:57.003009+08:00
2021-04-09T11:43:58.004714+08:00
2021-04-09T11:43:58.004756+08:00
2021-04-09T11:43:59.005378+08:00
2021-04-09T11:43:59.005552+08:00
2021-04-09T11:43:57.120087+08:00
2021-04-09T11:43:57.120364+08:00
2021-04-09T11:43:58.120769+08:00
2021-04-09T11:43:58.120806+08:00
2021-04-09T11:43:59.124919+08:00
2021-04-09T11:43:59.124973+08:00
reader.py
View file @
014ce6dd
import
os
def
readFile
(
fileName
):
def
readFile
(
fileName
=
'msg.log'
):
# 查询并读取文件
data
=
[]
for
root
,
dirs
,
files
in
os
.
walk
(
'./log/'
):
for
file
in
files
:
if
fileName
in
file
:
with
open
(
os
.
path
.
join
(
'./log/'
,
file
))
as
f
:
lines
=
f
.
readlines
()
for
line
in
lines
:
data
.
append
(
line
.
split
())
with
open
(
os
.
path
.
join
(
'./log/'
,
fileName
))
as
f
:
lines
=
f
.
readlines
()
for
line
in
lines
:
line
=
line
.
strip
(
'
\n
'
)
data
.
append
(
line
)
return
data
def
initData
():
# 初始化数据
receiveLog
=
readFile
(
'ChatReceive'
)
replyLog
=
readFile
(
'Reply'
)
data
=
[]
log
=
readFile
()
sendLog
=
[
eval
(
x
)
for
x
in
log
if
'sendMsg'
in
x
]
replyLog
=
[
eval
(
x
)
for
x
in
log
if
'sendReplyMsg'
in
x
]
receiveLog
=
[
eval
(
x
)
for
x
in
log
if
'receivedMsg'
in
x
]
for
i
in
receiveLog
:
for
j
in
replyLog
:
if
i
[
0
]
==
j
[
0
]:
i
.
insert
(
2
,
j
[
1
])
break
# print(receiveLog
)
r
eturn
receiveLog
print
(
sendLog
[
0
])
print
(
replyLog
[
0
])
print
(
receiveLog
[
0
])
# sd = sorted(sendLog, key=lambda x: x['msgSendTime'], reverse=False)
rp
=
sorted
(
replyLog
,
key
=
lambda
x
:
x
[
'logId'
],
reverse
=
False
)
r
c
=
sorted
(
receiveLog
,
key
=
lambda
x
:
x
[
'logId'
],
reverse
=
False
)
# 找出sendLog和receiveLog中发送时间不一致的记录
# for i in sd:
# for j in rc:
# if i['msgId'] == j['msgId']:
# if i['msgSendTime'] != j['msgSendTime']:
# print(i['msgId'], i['msgSendTime'], j['msgSendTime'])
# break
# else:
# print(i)
initData
()
for
i
in
rc
:
for
index
,
j
in
enumerate
(
rp
):
if
i
[
'logId'
]
==
j
[
'logId'
]:
data
.
append
(
{
'logId'
:
i
[
'logId'
],
'msgSendTime'
:
i
[
'msgSendTime'
],
'msgSendReplyTime'
:
j
[
'msgSendReplyTime'
],
'msgReceiveTime'
:
i
[
'msgReceiveTime'
]})
del
rp
[
index
]
break
else
:
print
(
'重复/未找到的logId:'
,
i
[
'logId'
],
i
[
'msgReceiveTime'
])
return
data
Write
Preview
Markdown
is supported
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