Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
f860e4e2
Commit
f860e4e2
authored
Feb 05, 2010
by
Vladislav Vaintroub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug#50057: 'SHOW PROFILE CPU' port for Windows.
Patch contributed by Alex Budovski.
parent
eed06395
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
sql/sql_profile.cc
sql/sql_profile.cc
+43
-0
sql/sql_profile.h
sql/sql_profile.h
+2
-0
No files found.
sql/sql_profile.cc
View file @
f860e4e2
...
...
@@ -134,6 +134,26 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table)
#define RUSAGE_USEC(tv) ((tv).tv_sec*1000*1000 + (tv).tv_usec)
#define RUSAGE_DIFF_USEC(tv1, tv2) (RUSAGE_USEC((tv1))-RUSAGE_USEC((tv2)))
#ifdef _WIN32
static
ULONGLONG
FileTimeToQuadWord
(
FILETIME
*
ft
)
{
// Overlay FILETIME onto a ULONGLONG.
union
{
ULONGLONG
qwTime
;
FILETIME
ft
;
}
u
;
u
.
ft
=
*
ft
;
return
u
.
qwTime
;
}
// Get time difference between to FILETIME objects in seconds.
static
double
GetTimeDiffInSeconds
(
FILETIME
*
a
,
FILETIME
*
b
)
{
return
((
FileTimeToQuadWord
(
a
)
-
FileTimeToQuadWord
(
b
))
/
1e7
);
}
#endif
PROF_MEASUREMENT
::
PROF_MEASUREMENT
(
QUERY_PROFILE
*
profile_arg
,
const
char
*
status_arg
)
...
...
@@ -224,6 +244,12 @@ void PROF_MEASUREMENT::collect()
time_usecs
=
(
double
)
my_getsystime
()
/
10.0
;
/* 1 sec was 1e7, now is 1e6 */
#ifdef HAVE_GETRUSAGE
getrusage
(
RUSAGE_SELF
,
&
rusage
);
#elif defined(_WIN32)
FILETIME
ftDummy
;
// NOTE: Get{Process|Thread}Times has a granularity of the clock interval,
// which is typically ~15ms. So intervals shorter than that will not be
// measurable by this function.
GetProcessTimes
(
GetCurrentProcess
(),
&
ftDummy
,
&
ftDummy
,
&
ftKernel
,
&
ftUser
);
#endif
}
...
...
@@ -589,6 +615,23 @@ int PROFILING::fill_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond)
(
1000.0
*
1000
),
&
cpu_stime_decimal
);
table
->
field
[
4
]
->
store_decimal
(
&
cpu_utime_decimal
);
table
->
field
[
5
]
->
store_decimal
(
&
cpu_stime_decimal
);
table
->
field
[
4
]
->
set_notnull
();
table
->
field
[
5
]
->
set_notnull
();
#elif defined(_WIN32)
my_decimal
cpu_utime_decimal
,
cpu_stime_decimal
;
double2my_decimal
(
E_DEC_FATAL_ERROR
,
GetTimeDiffInSeconds
(
&
entry
->
ftUser
,
&
previous
->
ftUser
),
&
cpu_utime_decimal
);
double2my_decimal
(
E_DEC_FATAL_ERROR
,
GetTimeDiffInSeconds
(
&
entry
->
ftKernel
,
&
previous
->
ftKernel
),
&
cpu_stime_decimal
);
// Store the result.
table
->
field
[
4
]
->
store_decimal
(
&
cpu_utime_decimal
);
table
->
field
[
5
]
->
store_decimal
(
&
cpu_stime_decimal
);
table
->
field
[
4
]
->
set_notnull
();
...
...
sql/sql_profile.h
View file @
f860e4e2
...
...
@@ -173,6 +173,8 @@ class PROF_MEASUREMENT
char
*
status
;
#ifdef HAVE_GETRUSAGE
struct
rusage
rusage
;
#elif defined(_WIN32)
FILETIME
ftKernel
,
ftUser
;
#endif
char
*
function
;
...
...
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