Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
d2c18653
Commit
d2c18653
authored
May 23, 2017
by
Thomas Van Lenten
Committed by
GitHub
May 23, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3103 from sergiocampama/perf
Adds serial and parallel parsing tests.
parents
85466206
2465ae7e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
0 deletions
+106
-0
GPBPerfTests.m
objectivec/Tests/GPBPerfTests.m
+106
-0
No files found.
objectivec/Tests/GPBPerfTests.m
View file @
d2c18653
...
...
@@ -64,6 +64,112 @@ static const uint32_t kRepeatedCount = 100;
}];
}
-
(
void
)
testMessageSerialParsingPerformance
{
// This and the next test are meant to monitor that the parsing functionality of protos does not
// lock across threads when parsing different instances. The Serial version of the test should run
// around ~2 times slower than the Parallel version since it's parsing the protos in the same
// thread.
TestAllTypes
*
allTypesMessage
=
[
TestAllTypes
message
];
[
self
setAllFields
:
allTypesMessage
repeatedCount
:
2
];
NSData
*
allTypesData
=
allTypesMessage
.
data
;
[
self
measureBlock
:
^
{
for
(
int
i
=
0
;
i
<
500
;
++
i
)
{
[
TestAllTypes
parseFromData
:
allTypesData
error
:
NULL
];
[
TestAllTypes
parseFromData
:
allTypesData
error
:
NULL
];
}
}];
}
-
(
void
)
testMessageParallelParsingPerformance
{
// This and the previous test are meant to monitor that the parsing functionality of protos does
// not lock across threads when parsing different instances. The Serial version of the test should
// run around ~2 times slower than the Parallel version since it's parsing the protos in the same
// thread.
TestAllTypes
*
allTypesMessage
=
[
TestAllTypes
message
];
[
self
setAllFields
:
allTypesMessage
repeatedCount
:
2
];
NSData
*
allTypesData
=
allTypesMessage
.
data
;
dispatch_queue_t
concurrentQueue
=
dispatch_queue_create
(
"perfQueue"
,
DISPATCH_QUEUE_CONCURRENT
);
[
self
measureBlock
:
^
{
for
(
int
i
=
0
;
i
<
500
;
++
i
)
{
dispatch_group_t
group
=
dispatch_group_create
();
dispatch_group_async
(
group
,
concurrentQueue
,
^
{
[
TestAllTypes
parseFromData
:
allTypesData
error
:
NULL
];
});
dispatch_group_async
(
group
,
concurrentQueue
,
^
{
[
TestAllTypes
parseFromData
:
allTypesData
error
:
NULL
];
});
dispatch_group_notify
(
group
,
concurrentQueue
,
^
{});
dispatch_release
(
group
);
}
}];
dispatch_release
(
concurrentQueue
);
}
-
(
void
)
testMessageSerialExtensionsParsingPerformance
{
// This and the next test are meant to monitor that the parsing functionality of protos does not
// lock across threads when parsing different instances when using extensions. The Serial version
// of the test should run around ~2 times slower than the Parallel version since it's parsing the
// protos in the same thread.
TestAllExtensions
*
allExtensionsMessage
=
[
TestAllExtensions
message
];
[
self
setAllExtensions
:
allExtensionsMessage
repeatedCount
:
2
];
NSData
*
allExtensionsData
=
allExtensionsMessage
.
data
;
[
self
measureBlock
:
^
{
for
(
int
i
=
0
;
i
<
500
;
++
i
)
{
[
TestAllExtensions
parseFromData
:
allExtensionsData
extensionRegistry
:[
self
extensionRegistry
]
error:
NULL
];
[
TestAllExtensions
parseFromData
:
allExtensionsData
extensionRegistry
:[
self
extensionRegistry
]
error:
NULL
];
}
}];
}
-
(
void
)
testMessageParallelExtensionsParsingPerformance
{
// This and the previous test are meant to monitor that the parsing functionality of protos does
// not lock across threads when parsing different instances when using extensions. The Serial
// version of the test should run around ~2 times slower than the Parallel version since it's
// parsing the protos in the same thread.
TestAllExtensions
*
allExtensionsMessage
=
[
TestAllExtensions
message
];
[
self
setAllExtensions
:
allExtensionsMessage
repeatedCount
:
2
];
NSData
*
allExtensionsData
=
allExtensionsMessage
.
data
;
dispatch_queue_t
concurrentQueue
=
dispatch_queue_create
(
"perfQueue"
,
DISPATCH_QUEUE_CONCURRENT
);
[
self
measureBlock
:
^
{
for
(
int
i
=
0
;
i
<
500
;
++
i
)
{
dispatch_group_t
group
=
dispatch_group_create
();
dispatch_group_async
(
group
,
concurrentQueue
,
^
{
[
TestAllExtensions
parseFromData
:
allExtensionsData
extensionRegistry
:[
UnittestRoot
extensionRegistry
]
error:
NULL
];
});
dispatch_group_async
(
group
,
concurrentQueue
,
^
{
[
TestAllExtensions
parseFromData
:
allExtensionsData
extensionRegistry
:[
UnittestRoot
extensionRegistry
]
error:
NULL
];
});
dispatch_group_notify
(
group
,
concurrentQueue
,
^
{});
dispatch_release
(
group
);
}
}];
dispatch_release
(
concurrentQueue
);
}
-
(
void
)
testExtensionsPerformance
{
[
self
measureBlock
:
^
{
for
(
int
i
=
0
;
i
<
200
;
++
i
)
{
...
...
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