Skip to content

Commit f7526b5

Browse files
committed
2 parents b05b433 + b669efd commit f7526b5

File tree

130 files changed

+1476
-1056
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+1476
-1056
lines changed

frameworks/C/h2o/h2o.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ RUN apt-get -yqq update && \
3333
ruby \
3434
systemtap-sdt-dev
3535

36-
ARG H2O_VERSION=18b175f71ede08b50d3e5ae8303dacef3ea510fc
36+
ARG H2O_VERSION=c54c63285b52421da2782f028022647fc2ea3dd1
3737

3838
WORKDIR /tmp/h2o-build
3939
RUN curl -LSs "https://github.com/h2o/h2o/archive/${H2O_VERSION}.tar.gz" | \

frameworks/C/h2o/src/handlers/world.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,10 @@ static int do_multiple_queries(bool do_update, bool use_cache, h2o_req_t *req)
238238
const size_t num_query = get_query_number(req);
239239

240240
// MAX_QUERIES is a relatively small number, say less than or equal to UINT16_MAX, so assume no
241-
// overflow in the following arithmetic operations.
242-
assert(num_query && num_query <= MAX_QUERIES && num_query <= UINT16_MAX);
241+
// unsigned overflow in the following arithmetic operations.
242+
static_assert(MAX_QUERIES <= UINT16_MAX,
243+
"potential out-of-bounds memory accesses in the following code");
244+
assert(num_query && num_query <= MAX_QUERIES);
243245

244246
size_t base_size = offsetof(multiple_query_ctx_t, res) + num_query * sizeof(query_result_t);
245247

frameworks/Dart/dart3/.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# From https://hub.docker.com/_/dart
2+
.dockerignore
3+
Dockerfile
4+
build/
5+
.dart_tool/
6+
.git/
7+
.github/
8+
.gitignore
9+
.packages

frameworks/Dart/dart3/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# https://dart.dev/guides/libraries/private-files
2+
# Created by `dart pub`
3+
.dart_tool/
4+
*.lock
5+
!bin

frameworks/Dart/dart3/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Dart 3 Benchmarking Test
2+
3+
### Test Type Implementation Source Code
4+
5+
- [JSON](server.dart)
6+
- [PLAINTEXT](server.dart)
7+
8+
## Important Libraries
9+
10+
The tests were run with:
11+
12+
- [Dart v3.4.4](https://dart.dev/)
13+
14+
## Test URLs
15+
16+
### JSON
17+
18+
http://localhost:8080/json
19+
20+
### PLAINTEXT
21+
22+
http://localhost:8080/plaintext
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:lints/recommended.yaml
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"framework": "dart3",
3+
"tests": [
4+
{
5+
"default": {
6+
"json_url": "/json",
7+
"plaintext_url": "/plaintext",
8+
"port": 8080,
9+
"approach": "Stripped",
10+
"classification": "Platform",
11+
"database": "None",
12+
"framework": "None",
13+
"language": "Dart",
14+
"flavor": "None",
15+
"orm": "None",
16+
"platform": "None",
17+
"webserver": "None",
18+
"os": "Linux",
19+
"database_os": "Linux",
20+
"display_name": "dart3",
21+
"notes": "",
22+
"versus": "None"
23+
}
24+
}
25+
]
26+
}

frameworks/Dart/dart3/bin/server.dart

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import 'dart:convert';
2+
import 'dart:io';
3+
import 'dart:isolate';
4+
5+
final _encoder = JsonUtf8Encoder();
6+
7+
void main(List<String> _) async {
8+
/// Create an [Isolate] containinig an [HttpServer]
9+
/// for each processor after the first
10+
for (var i = 1; i < Platform.numberOfProcessors; i++) {
11+
await Isolate.spawn(_startServer, _);
12+
}
13+
14+
/// Create a [HttpServer] for the first processor
15+
await _startServer(_);
16+
}
17+
18+
/// Creates and setup a [HttpServer]
19+
Future<void> _startServer(List<String> _) async {
20+
/// Binds the [HttpServer] on `0.0.0.0:8080`.
21+
final server = await HttpServer.bind(
22+
InternetAddress('0.0.0.0', type: InternetAddressType.IPv4),
23+
8080,
24+
shared: true,
25+
);
26+
27+
/// Sets [HttpServer]'s [serverHeader].
28+
server
29+
..defaultResponseHeaders.clear()
30+
..serverHeader = 'dart';
31+
32+
/// Handles [HttpRequest]'s from [HttpServer].
33+
await for (final request in server) {
34+
switch (request.uri.path) {
35+
case '/json':
36+
_jsonTest(request);
37+
break;
38+
case '/plaintext':
39+
_plaintextTest(request);
40+
break;
41+
default:
42+
_sendResponse(request, HttpStatus.notFound);
43+
}
44+
}
45+
}
46+
47+
/// Completes the given [request] by writing the [bytes] with the given
48+
/// [statusCode] and [type].
49+
void _sendResponse(
50+
HttpRequest request,
51+
int statusCode, {
52+
ContentType? type,
53+
List<int> bytes = const [],
54+
}) =>
55+
request.response
56+
..statusCode = statusCode
57+
..headers.contentType = type
58+
..headers.date = DateTime.now()
59+
..contentLength = bytes.length
60+
..add(bytes)
61+
..close();
62+
63+
/// Completes the given [request] by writing the [response] as JSON.
64+
void _sendJson(HttpRequest request, Object response) => _sendResponse(
65+
request,
66+
HttpStatus.ok,
67+
type: ContentType.json,
68+
bytes: _encoder.convert(response),
69+
);
70+
71+
/// Completes the given [request] by writing the [response] as plain text.
72+
void _sendText(HttpRequest request, String response) => _sendResponse(
73+
request,
74+
HttpStatus.ok,
75+
type: ContentType.text,
76+
bytes: utf8.encode(response),
77+
);
78+
79+
/// Responds with the JSON test to the [request].
80+
void _jsonTest(HttpRequest request) => _sendJson(
81+
request,
82+
const {'message': 'Hello, World!'},
83+
);
84+
85+
/// Responds with the plaintext test to the [request].
86+
void _plaintextTest(HttpRequest request) => _sendText(
87+
request,
88+
'Hello, World!',
89+
);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
FROM dart:3.5 AS builder
3+
4+
COPY . /app
5+
WORKDIR /app
6+
RUN mkdir build
7+
RUN dart compile exe ./bin/server.dart -o build/server
8+
9+
FROM scratch
10+
COPY --from=builder /runtime/ /
11+
COPY --from=builder /app/build /bin
12+
13+
EXPOSE 8080
14+
CMD ["server"]

frameworks/Dart/dart3/pubspec.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: dartbenchmark
2+
description: A benchmark of dart
3+
environment:
4+
sdk: '>=3.5.0 <4.0.0'
5+
6+
dev_dependencies:
7+
lints: ^4.0.0

0 commit comments

Comments
 (0)