-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#22 one permance test only contains one test case
- Loading branch information
Showing
5 changed files
with
150 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,4 +60,4 @@ build | |
|
||
# UAPI project files | ||
#================================= | ||
performance.txt | ||
**/perf/*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The folder holds performance tests result |
76 changes: 76 additions & 0 deletions
76
uapi.service/src/test/groovy/perf/registry/SimpleServiceByMultipleThread.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (C) 2017. The UAPI Authors | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at the LICENSE file. | ||
* | ||
* You must gained the permission from the authors if you want to | ||
* use the project into a commercial product | ||
*/ | ||
|
||
package perf.registry | ||
|
||
import spock.lang.Ignore | ||
import spock.lang.Specification | ||
import uapi.rx.Looper | ||
import uapi.service.IService | ||
import uapi.service.internal.Registry | ||
|
||
import java.util.stream.Collectors | ||
|
||
/** | ||
* Performance test on simple service by multiple thread | ||
*/ | ||
@Ignore | ||
class SimpleServiceByMultipleThread extends Specification { | ||
|
||
def static writer | ||
|
||
def setupSpec() { | ||
def file = new File('perf/simpleServiceByMultipleThread.txt') | ||
if (file.exists()) { | ||
file.delete() | ||
} | ||
writer = file.newPrintWriter() | ||
} | ||
|
||
def cleanupSpec() { | ||
if (writer != null) { | ||
writer.flush() | ||
writer.close() | ||
} | ||
} | ||
|
||
def 'Test register and find out simple service by single thread'() { | ||
when: | ||
System.out.println("start") | ||
|
||
then: | ||
Looper.on(uapi.common.Range.from(1).to(loopCount)) | ||
.foreach({time -> | ||
def registry = new Registry() | ||
def services = [] as List<IService> | ||
def svcIds = [] | ||
Looper.on(uapi.common.Range.from(svcIdFrom).to(svcIdTo)) | ||
.next({id -> svcIds.add(id)}) | ||
.foreach({id -> services.add(Mock(IService) { | ||
getIds() >> [ "svc_${id}" ] | ||
})}) | ||
|
||
def startTime = System.currentTimeMillis() | ||
Looper.on(services).foreach({service -> registry.register(service)}) | ||
|
||
svcIds.parallelStream() | ||
.map({id -> registry.findService("svc_${id}")}) | ||
.filter({svc -> svc != null}) | ||
.collect(Collectors.toList()).size() == svcIdTo - svcIdFrom + 1 | ||
def endTime = System.currentTimeMillis() | ||
writer.println("${endTime - startTime}ms") | ||
System.out.println("${endTime - startTime}") | ||
}) | ||
|
||
|
||
where: | ||
svcIdFrom | svcIdTo | loopCount | ||
1 | 1000 | 10 | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
uapi.service/src/test/groovy/perf/registry/SimpleServiceBySingleThread.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (C) 2017. The UAPI Authors | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at the LICENSE file. | ||
* | ||
* You must gained the permission from the authors if you want to | ||
* use the project into a commercial product | ||
*/ | ||
|
||
package perf.registry | ||
|
||
import spock.lang.Ignore | ||
import spock.lang.Specification | ||
import uapi.rx.Looper | ||
import uapi.service.IService | ||
import uapi.service.internal.Registry | ||
|
||
/** | ||
* Performance test on simple service by single thread | ||
*/ | ||
@Ignore | ||
class SimpleServiceBySingleThread extends Specification { | ||
|
||
def static writer | ||
|
||
def setupSpec() { | ||
def file = new File('perf/simpleServiceBySingleThread.txt') | ||
if (file.exists()) { | ||
file.delete() | ||
} | ||
writer = file.newPrintWriter() | ||
} | ||
|
||
def cleanupSpec() { | ||
if (writer != null) { | ||
writer.flush() | ||
writer.close() | ||
} | ||
} | ||
|
||
def 'Test register and find out simple service by single thread'() { | ||
when: | ||
System.out.println("start") | ||
|
||
then: | ||
Looper.on(uapi.common.Range.from(1).to(loopCount)) | ||
.foreach({time -> | ||
def registry = new Registry() | ||
def services = [] as List<IService> | ||
Looper.on(uapi.common.Range.from(svcIdFrom).to(svcIdTo)) | ||
.foreach({id -> services.add(Mock(IService) { | ||
getIds() >> [ "svc_${id}" ] | ||
})}) | ||
|
||
def startTime = System.currentTimeMillis() | ||
Looper.on(services).foreach({service -> registry.register(service)}) | ||
|
||
Looper.on(uapi.common.Range.from(svcIdFrom).to(svcIdTo)) | ||
.map({id -> registry.findService("svc_${id}")}) | ||
.filter({svc -> svc != null}) | ||
.toList().size() == svcIdTo - svcIdFrom + 1 | ||
def endTime = System.currentTimeMillis() | ||
writer.println("${endTime - startTime}ms") | ||
System.out.println("${endTime - startTime}") | ||
}) | ||
|
||
|
||
where: | ||
svcIdFrom | svcIdTo | loopCount | ||
1 | 1000 | 10 | ||
} | ||
} |
98 changes: 0 additions & 98 deletions
98
uapi.service/src/test/groovy/uapi/service/internal/RegistryPerformanceTest.groovy
This file was deleted.
Oops, something went wrong.