Skip to content
Merged

aa #5

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions frameworks/CSharp/beetlex/PlatformBenchmarks/DBRaw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ private Fortune[] GetFortuneBuffer()

public async Task<World> LoadSingleQueryRow()
{
using (var db = new NpgsqlConnection(_connectionString))
using (var db = _dbProviderFactory.CreateConnection())
{
db.ConnectionString = _connectionString;
await db.OpenAsync();
SingleCommand.Connection = db;
mID.TypedValue = _random.Next(1, 10001);
Expand All @@ -101,12 +102,12 @@ async Task<World> ReadSingleRow(DbConnection connection, DbCommand cmd)

public async Task<ArraySegment<World>> LoadMultipleQueriesRows(int count)
{
using (var db = new NpgsqlConnection(_connectionString))
using (var db = _dbProviderFactory.CreateConnection())
{
db.ConnectionString = _connectionString;
await db.OpenAsync();
return await LoadMultipleRows(count, db);
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public partial class HttpHandler : ServerHandlerBase

private static AsciiString _httpsuccess = new AsciiString("HTTP/1.1 200 OK\r\n");

private static readonly AsciiString _headerServer = "Server: TFB\r\n";
private static readonly AsciiString _headerServer = "Server: B\r\n";

private static readonly AsciiString _headerContentLength = "Content-Length: ";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BeetleX" Version="1.6.5.38-beta" />
<PackageReference Include="BeetleX" Version="1.6.5.41" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Npgsql" Version="5.0.3" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
physicalTag=Citrine
cloudTag=Azure

mongodbPhysicalPoolSize=200
mongodbPhysicalPoolSize=100
mongodbCloudPoolSize=100
mongodbDefaultPoolSize=50

postgresPhysicalPoolSize=112
postgresPhysicalPoolSize=56
postgresCloudPoolSize=16
postgresDefaultPoolSize=10
39 changes: 38 additions & 1 deletion frameworks/Java/redkale/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"framework": "redkale",
"tests": [{
"default": {
"default": {
"plaintext_url": "/plaintext",
"json_url": "/json",
"port": 8080,
Expand Down Expand Up @@ -41,6 +41,43 @@
"display_name": "redkale",
"notes": "",
"versus": "Redkale"
},
"io": {
"plaintext_url": "/plaintext",
"json_url": "/json",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
"database": "Postgres",
"framework": "Redkale",
"language": "Java",
"flavor": "None",
"orm": "Raw",
"platform": "Redkale",
"webserver": "Redkale",
"os": "Linux",
"database_os": "Linux",
"display_name": "redkale",
"notes": "",
"versus": "Redkale"
},
"json": {
"json_url": "/json",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
"database": "Postgres",
"framework": "Redkale",
"language": "Java",
"flavor": "None",
"orm": "Raw",
"platform": "Redkale",
"webserver": "Redkale",
"os": "Linux",
"database_os": "Linux",
"display_name": "redkale",
"notes": "",
"versus": "Redkale"
}
}]
}
13 changes: 6 additions & 7 deletions frameworks/Java/redkale/conf/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
<application port="8585">

<resources>
<executor threads="0"/>
<properties>
<executor threads="0"/>
<properties>
<property name="system.property.convert.tiny" value="false"/>
<property name="system.property.http.response.header.connection" value="none"/>
</properties>
</resources>

<server protocol="HTTP" lazy="true" port="8080">

<response>
<contenttype plain="text/plain" json="application/json"/>
<date period="1000"/>
</response>

<contenttype plain="text/plain" json="application/json"/>
<date period="1000"/>
</response>
<services autoload="true"/>
<rest autoload="true"/>
<servlets autoload="true"/>
Expand Down
8 changes: 5 additions & 3 deletions frameworks/Java/redkale/conf/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<shared-cache-mode>ALL</shared-cache-mode>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://tfb-database:5432/hello_world"/>
<property name="javax.persistence.jdbc.prepare" value="true"/>
<property name="javax.persistence.jdbc.preparecache" value="true"/>
<property name="javax.persistence.connections.limit" value="512"/>
<property name="javax.persistence.jdbc.user" value="benchmarkdbuser"/>
<property name="javax.persistence.jdbc.password" value="benchmarkdbpass"/>
</properties>
Expand All @@ -16,10 +17,11 @@
<shared-cache-mode>ALL</shared-cache-mode>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://tfb-database:5432/hello_world"/>
<property name="javax.persistence.jdbc.prepare" value="true"/>
<property name="javax.persistence.jdbc.preparecache" value="true"/>
<property name="javax.persistence.connections.limit" value="512"/>
<property name="javax.persistence.jdbc.user" value="benchmarkdbuser"/>
<property name="javax.persistence.jdbc.password" value="benchmarkdbpass"/>
</properties>
</persistence-unit>

</persistence>
25 changes: 25 additions & 0 deletions frameworks/Java/redkale/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,28 @@ orm = "Raw"
platform = "Redkale"
webserver = "Redkale"
versus = "Redkale"

[io]
urls.plaintext = "/plaintext"
urls.json = "/json"
approach = "Realistic"
classification = "Fullstack"
database = "None"
database_os = "Linux"
os = "Linux"
orm = "Raw"
platform = "Redkale"
webserver = "Redkale"
versus = "Redkale"

[json]
urls.json = "/json"
approach = "Realistic"
classification = "Fullstack"
database = "None"
database_os = "Linux"
os = "Linux"
orm = "Raw"
platform = "Redkale"
webserver = "Redkale"
versus = "Redkale"
15 changes: 15 additions & 0 deletions frameworks/Java/redkale/redkale-io.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM maven:3.6.1-jdk-11-slim as maven
WORKDIR /redkale
COPY src src
COPY conf conf
COPY pom.xml pom.xml
RUN mvn package -q

FROM openjdk:11.0.3-jdk-slim
WORKDIR /redkale
COPY conf conf
COPY --from=maven /redkale/target/redkale-benchmark-1.0.0.jar redkale-benchmark.jar

EXPOSE 8080

CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:AutoBoxCacheMax=80000", "-XX:BiasedLockingStartupDelay=500", "-Dio.direct.fd=true", "-DAPP_HOME=./", "-jar", "redkale-benchmark.jar"]
15 changes: 15 additions & 0 deletions frameworks/Java/redkale/redkale-json.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM maven:3.6.1-jdk-11-slim as maven
WORKDIR /redkale
COPY src src
COPY conf conf
COPY pom.xml pom.xml
RUN mvn package -q

FROM openjdk:11.0.3-jdk-slim
WORKDIR /redkale
COPY conf conf
COPY --from=maven /redkale/target/redkale-benchmark-1.0.0.jar redkale-benchmark.jar

EXPOSE 8080

CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:AutoBoxCacheMax=80000", "-XX:BiasedLockingStartupDelay=500", "-Djson.direct.test=true", "-DAPP_HOME=./", "-jar", "redkale-benchmark.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.redkale.net.http.*;
import org.redkale.service.AbstractService;
import org.redkale.source.*;
import org.redkale.util.AnyValue;
import org.redkale.util.StringWrapper;

/**
*
Expand All @@ -24,54 +24,35 @@ public class Service extends AbstractService {

private static final byte[] helloBytes = "Hello, world!".getBytes();

private final Random random = new Random();
private final ThreadLocal<Random> localRandom = ThreadLocal.withInitial(Random::new);

@Resource
private DataSource source;


@RestMapping(name = "json")
public Message getHelloMessage() {
return new Message("Hello, World!");
}

@RestMapping(name = "plaintext")
public byte[] getHelloBytes() {
return helloBytes;
}

@RestMapping(name = "cached-worlds")
public CachedWorld[] cachedWorlds(int q) {
final int size = Math.min(500, Math.max(1, q));
final CachedWorld[] worlds = new CachedWorld[size];
for (int i = 0; i < size; i++) {
worlds[i] = source.find(CachedWorld.class, randomId());
}
return worlds;
@RestMapping(name = "json")
public Message getHelloMessage() {
return new Message("Hello, World!");
}

@RestMapping(name = "db")
public CompletableFuture<World> findWorldAsync() {
return source.findAsync(World.class, randomId());
}

@RestMapping(name = "fortunes")
public CompletableFuture<HttpResult<String>> queryFortunes() {
return source.queryListAsync(Fortune.class).thenApply((fortunes) -> {
fortunes.add(new Fortune(0, "Additional fortune added at request time."));
Collections.sort(fortunes);
String html = FortunesTemplate.template(fortunes).render().toString();
return new HttpResult("text/html; charset=UTF-8", html);
});
}

@RestMapping(name = "queries")
public CompletableFuture<World[]> queryWorldAsync(int q) {
final int size = Math.min(500, Math.max(1, q));
final Random random = localRandom.get();
final World[] worlds = new World[size];

final AtomicInteger index = new AtomicInteger();
final Function<?, CompletableFuture> func = f -> source.findAsync(World.class, randomId())
.thenAccept((World v) -> worlds[index.getAndIncrement()] = v);
final Function<?, CompletableFuture> func = f -> source.findAsync(World.class, randomId(random))
.thenAccept(v -> worlds[index.getAndIncrement()] = v);
CompletableFuture future = func.apply(null);
for (int i = 1; i < size; i++) {
future = future.thenCompose(func);
Expand All @@ -82,25 +63,54 @@ public CompletableFuture<World[]> queryWorldAsync(int q) {
@RestMapping(name = "updates")
public CompletableFuture<World[]> updateWorldAsync(int q) {
final int size = Math.min(500, Math.max(1, q));
final Random random = localRandom.get();
final World[] worlds = new World[size];

final AtomicInteger index = new AtomicInteger();
final Function<?, CompletableFuture> func = f -> source.findAsync(World.class, randomId())
.thenApply((World v) -> {
worlds[index.getAndIncrement()] = v;
v.setRandomNumber(randomId());
return v;
});
final Function<?, CompletableFuture> func = f -> source.findAsync(World.class, randomId(random))
.thenAccept(v -> worlds[index.getAndIncrement()] = v.randomNumber(randomId(random)));
CompletableFuture future = func.apply(null);
for (int i = 1; i < size; i++) {
future = future.thenCompose(func);
}
return future.thenCompose(v -> {
Arrays.sort(worlds);
return source.updateAsync(worlds);
}).thenApply(v -> worlds);
return future.thenCompose(v -> source.updateAsync(sort(worlds))).thenApply(v -> worlds);
}

@RestMapping(name = "fortunes")
public CompletableFuture<HttpResult<String>> queryFortunes() {
return source.queryListAsync(Fortune.class).thenApply((fortunes) -> {
fortunes.add(new Fortune(0, "Additional fortune added at request time."));
String html = FortunesTemplate.template(sort(fortunes)).render().toString();
return new HttpResult("text/html; charset=utf-8", html);
});
}

@RestMapping(name = "cached-worlds")
public CachedWorld[] cachedWorlds(int q) {
final int size = Math.min(500, Math.max(1, q));
final Random random = localRandom.get();
final CachedWorld[] worlds = new CachedWorld[size];
for (int i = 0; i < size; i++) {
worlds[i] = source.find(CachedWorld.class, randomId(random));
}
return worlds;
}

private World[] sort(World[] words) {
Arrays.sort(words);
return words;
}

private List<Fortune> sort(List<Fortune> fortunes) {
Collections.sort(fortunes);
return fortunes;
}

private int randomId() {
return 1 + localRandom.get().nextInt(10000);
}

private int randomId(Random random) {
return 1 + random.nextInt(10000);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public class World implements Comparable<World> {

private int randomNumber;

public World randomNumber(int randomNumber) {
this.randomNumber = randomNumber;
return this;
}

public int getId() {
return id;
}
Expand Down
4 changes: 2 additions & 2 deletions frameworks/PHP/kumbiaphp/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"webserver": "None",
"os": "Linux",
"database_os": "Linux",
"display_name": "kumbiaphp-worker",
"display_name": "kumbiaphp-workerman",
"notes": "",
"versus": "workerman"
},
Expand All @@ -86,7 +86,7 @@
"webserver": "None",
"os": "Linux",
"database_os": "Linux",
"display_name": "kumbiaphp-worker",
"display_name": "kumbiaphp-workerman-mysql",
"notes": "",
"versus": "workerman"
}
Expand Down
Loading