Initial Dever 0.0.1
This commit is contained in:
commit
81233d098c
1479 files changed
+163782
No files matched your search
@@ -0,0 +1,486 @@
|
||||
use std::path::Path;
|
||||
#[path = "performance/auth/build.rs"]
|
||||
mod auth_build;
|
||||
#[path = "performance/build/mod.rs"]
|
||||
mod build;
|
||||
#[path = "performance/extended/mod.rs"]
|
||||
mod extended;
|
||||
#[path = "performance/transport/mod.rs"]
|
||||
mod transport;
|
||||
use build::compare;
|
||||
|
||||
fn main() {
|
||||
let core = Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("..")
|
||||
.canonicalize()
|
||||
.unwrap();
|
||||
if auth_build::run(&core) {
|
||||
return;
|
||||
}
|
||||
if extended::run(&core) || transport::run(&core) {
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--query") {
|
||||
compare(
|
||||
&core,
|
||||
"json-performance",
|
||||
"query",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/query/mod.rs")
|
||||
+ include_str!("performance/query/checks.rs")),
|
||||
&[],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--websocket-protocol") {
|
||||
compare(
|
||||
&core,
|
||||
"websocket",
|
||||
"websocket-protocol",
|
||||
&("mod peer {\n".to_owned()
|
||||
+ include_str!("performance/websocket/peer.rs")
|
||||
+ "\n}\nmod layers {\n"
|
||||
+ include_str!("performance/websocket/layers.rs")
|
||||
+ "\n}\nmod shared {\n"
|
||||
+ &include_str!("performance/websocket/shared/mod.rs").replace(
|
||||
"mod wire;",
|
||||
&("mod wire {\n".to_owned()
|
||||
+ include_str!("performance/websocket/shared/wire.rs")
|
||||
+ "\n}"),
|
||||
)
|
||||
+ "\n}\n"
|
||||
+ include_str!("performance/websocket/protocol.rs")),
|
||||
&[
|
||||
("WS_SEND_TEXT", "sendText"),
|
||||
("WS_SEND_BINARY", "sendBinary"),
|
||||
],
|
||||
&[("MESSAGE_TYPE", "Message")],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--websocket") {
|
||||
compare(
|
||||
&core,
|
||||
"websocket",
|
||||
"websocket",
|
||||
&("mod peer {\n".to_owned()
|
||||
+ include_str!("performance/websocket/peer.rs")
|
||||
+ "\n}\n"
|
||||
+ include_str!("performance/websocket/mod.rs")),
|
||||
&[
|
||||
("WS_SEND_TEXT", "sendText"),
|
||||
("WS_SEND_BINARY", "sendBinary"),
|
||||
("WS_SEND_MESSAGE", "sendMessage"),
|
||||
],
|
||||
&[("MESSAGE_TYPE", "Message")],
|
||||
);
|
||||
return;
|
||||
}
|
||||
let postgres = std::env::args().any(|argument| argument == "--database-postgres");
|
||||
if postgres || std::env::args().any(|argument| argument == "--database") {
|
||||
let reference = [
|
||||
include_str!("performance/database.rs"),
|
||||
include_str!("performance/database/setup.rs"),
|
||||
]
|
||||
.concat()
|
||||
+ &format!("const POSTGRES: bool = {postgres};\n");
|
||||
compare(
|
||||
&core,
|
||||
"database",
|
||||
if postgres {
|
||||
"database-postgres"
|
||||
} else {
|
||||
"database"
|
||||
},
|
||||
&reference,
|
||||
&[
|
||||
("GENERATED_READ", "demo.account.app.get"),
|
||||
("GENERATED_COUNT", "demo.account.app.count"),
|
||||
("GENERATED_CREATE", "demo.account.app.create"),
|
||||
("GENERATED_UPDATE", "demo.account.app.rename"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--json-document-phases") {
|
||||
compare(
|
||||
&core,
|
||||
"json-performance",
|
||||
"json-document-phases",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ "mod reference_writer {\n"
|
||||
+ include_str!("performance/json/writer.rs")
|
||||
+ "\n}\n"
|
||||
+ &include_str!("performance/json/document.rs")
|
||||
.replace("fn main()", "fn document_comparison()")
|
||||
+ include_str!("performance/json/phases.rs")),
|
||||
&[
|
||||
("GENERATED_DOCUMENT", "document"),
|
||||
("GENERATED_PARSE", "dever.json.parse"),
|
||||
("GENERATED_WRITE", "dever.json.stringify"),
|
||||
],
|
||||
&[("DOCUMENT_TYPE", "Document")],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--json-document") {
|
||||
compare(
|
||||
&core,
|
||||
"json-performance",
|
||||
"json-document",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ "mod reference_writer {\n"
|
||||
+ include_str!("performance/json/writer.rs")
|
||||
+ "\n}\n"
|
||||
+ include_str!("performance/json/document.rs")),
|
||||
&[("GENERATED_DOCUMENT", "document")],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--json") {
|
||||
compare(
|
||||
&core,
|
||||
"json-performance",
|
||||
"json",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/json.rs")
|
||||
+ include_str!("performance/json/property.rs")
|
||||
+ include_str!("performance/json/raw.rs")),
|
||||
&[
|
||||
("GENERATED_ENCODE", "encode"),
|
||||
("GENERATED_SCALAR_TEXT", "scalarText"),
|
||||
("GENERATED_SCALAR_FLOAT", "scalarFloat"),
|
||||
("GENERATED_FIXED_RECORD", "fixedRecord"),
|
||||
("GENERATED_LOOKUP", "lookup"),
|
||||
("GENERATED_UPDATE", "update"),
|
||||
("GENERATED_NESTED", "nested"),
|
||||
("GENERATED_ARRAY", "arrayText"),
|
||||
("GENERATED_DECODE", "decodeList"),
|
||||
("GENERATED_CAPTURED_DECODE", "decodeCaptured"),
|
||||
("GENERATED_ENUM_DECODE", "decodeState"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--tasks") {
|
||||
compare(
|
||||
&core,
|
||||
"task-performance",
|
||||
"tasks",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/task/reference.rs")
|
||||
+ include_str!("performance/task/mod.rs")
|
||||
+ include_str!("performance/task/shared.rs")
|
||||
+ include_str!("performance/task/worker.rs")
|
||||
+ include_str!("performance/task/scoped.rs")
|
||||
+ include_str!("performance/task/cleanup.rs")
|
||||
+ include_str!("performance/task/cancel.rs")
|
||||
+ include_str!("performance/task/lifecycle.rs")),
|
||||
&[
|
||||
("GENERATED_SYNC", "syncPair"),
|
||||
("GENERATED_ASYNC", "asyncPair"),
|
||||
("GENERATED_PARALLEL", "parallelSum"),
|
||||
("GENERATED_BLOCKING", "blockingSum"),
|
||||
("GENERATED_CANCEL", "cancel"),
|
||||
("GENERATED_TIMER", "timer"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--resources") {
|
||||
compare(
|
||||
&core,
|
||||
"resource-performance",
|
||||
"resources",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/resource/reference.rs")
|
||||
+ include_str!("performance/resource/mod.rs")),
|
||||
&[
|
||||
("GENERATED_OPEN", "openClose"),
|
||||
("GENERATED_READ", "readBytes"),
|
||||
("GENERATED_STREAM", "consume"),
|
||||
("GENERATED_PARTIAL", "resume"),
|
||||
("GENERATED_CLOSED", "closedStream"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--decimal-extra") {
|
||||
compare(
|
||||
&core,
|
||||
"standard",
|
||||
"decimal-extra",
|
||||
&[
|
||||
include_str!("performance/samples.rs"),
|
||||
include_str!("performance/numeric/standard.rs"),
|
||||
include_str!("performance/numeric/wire.rs"),
|
||||
include_str!("performance/numeric/storage.rs"),
|
||||
]
|
||||
.concat(),
|
||||
&[
|
||||
("DECIMAL_PARSE", "parseDecimal"),
|
||||
("DECIMAL_TEXT", "formatDecimal"),
|
||||
("DECIMAL_ROUND", "roundDecimal"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--decimal-ops") {
|
||||
compare(
|
||||
&core,
|
||||
"decimal",
|
||||
"decimal-ops",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/numeric/operations.rs")),
|
||||
&[
|
||||
("GENERATED_ADD", "add"),
|
||||
("GENERATED_SUBTRACT", "subtract"),
|
||||
("GENERATED_MULTIPLY", "multiply"),
|
||||
("GENERATED_DIVIDE", "divide"),
|
||||
("GENERATED_CALCULATE", "calculate"),
|
||||
("GENERATED_SCALED", "scaled"),
|
||||
("GENERATED_SCALE", "scale"),
|
||||
("GENERATED_CONVERT", "convert"),
|
||||
("GENERATED_CONSTANTS", "constants"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--decimal-sum") {
|
||||
compare(
|
||||
&core,
|
||||
"decimal",
|
||||
"decimal",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/numeric/decimal.rs")),
|
||||
&[("GENERATED_DECIMAL_SUM", "total")],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--float-audit") {
|
||||
compare(
|
||||
&core,
|
||||
"numeric",
|
||||
"float",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/numeric/float.rs")),
|
||||
&[
|
||||
("GENERATED_FLOAT_TOTAL", "floatTotal"),
|
||||
("GENERATED_FLOAT", "floatClass"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--ranges") {
|
||||
compare(
|
||||
&core,
|
||||
"ranges",
|
||||
"ranges",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/numeric/range.rs")),
|
||||
&[("GENERATED_TOTAL", "total"), ("GENERATED_RATES", "rates")],
|
||||
&[("PORT_TYPE", "Port"), ("RATE_TYPE", "Rate")],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--scalar-audit") {
|
||||
compare(
|
||||
&core,
|
||||
"package",
|
||||
"scalar",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/package/scalar.rs")),
|
||||
&[
|
||||
("GENERATED_DISPATCH", "main.dispatch"),
|
||||
("GENERATED_ADJUST", "main.adjust"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--numeric") {
|
||||
compare(
|
||||
&core,
|
||||
"numeric",
|
||||
"numeric",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/numeric/mod.rs")),
|
||||
&[
|
||||
("GENERATED_DECIMAL", "decimalClass"),
|
||||
("GENERATED_EDGE", "decimalEdge"),
|
||||
("GENERATED_FLOAT", "floatClass"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--application") {
|
||||
compare(
|
||||
&core,
|
||||
"application",
|
||||
"application",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/application/mod.rs")),
|
||||
&[
|
||||
("GENERATED_GREETING", "demo.greeting.greet"),
|
||||
("GENERATED_ECHO", "demo.greeting.echo"),
|
||||
("GENERATED_DOUBLE", "demo.greeting.double"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--packages") {
|
||||
compare(
|
||||
&core,
|
||||
"package",
|
||||
"package",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/package/mod.rs")),
|
||||
&[
|
||||
("GENERATED_MAP", "calc.batch.mapValues"),
|
||||
("GENERATED_TOTAL", "calc.batch.total"),
|
||||
("GENERATED_DISPATCH_TOTAL", "main.dispatchTotal"),
|
||||
("GENERATED_DISPATCH", "main.dispatch"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--ids") {
|
||||
compare(
|
||||
&core,
|
||||
"id",
|
||||
"id",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/id/mod.rs")),
|
||||
&[
|
||||
("GENERATED_ROUNDTRIP", "roundtrip"),
|
||||
("GENERATED_ENCODE_ALL", "encodeAll"),
|
||||
("GENERATED_COMPARE", "countEqual"),
|
||||
("GENERATED_LOOKUP", "lookup"),
|
||||
("GENERATED_BUILD_MAP", "buildMap"),
|
||||
("GENERATED_ENTRIES", "buildEntries"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--bytes") {
|
||||
compare(
|
||||
&core,
|
||||
"bytes",
|
||||
"bytes",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/bytes/mod.rs")),
|
||||
&[
|
||||
("GENERATED_TOTAL", "total"),
|
||||
("GENERATED_EACH", "incremented"),
|
||||
("GENERATED_ENCODE", "encode"),
|
||||
("GENERATED_DECODE", "decode"),
|
||||
("GENERATED_CONVERT", "convert"),
|
||||
("GENERATED_SLICE", "copyBytes"),
|
||||
("GENERATED_JOIN", "join"),
|
||||
("GENERATED_ROUNDTRIP", "roundtrip"),
|
||||
("GENERATED_IDENTITY", "identity"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--collections") {
|
||||
compare(
|
||||
&core,
|
||||
"collection",
|
||||
"collection",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/collection.rs")),
|
||||
&[
|
||||
("GENERATED_MAP", "mapInts"),
|
||||
("GENERATED_FILTER", "filterInts"),
|
||||
("GENERATED_FIND", "findInt"),
|
||||
("GENERATED_SUM", "projectSum"),
|
||||
("GENERATED_FOLD", "foldSum"),
|
||||
("GENERATED_STOP", "stopSum"),
|
||||
("GENERATED_ROWS", "mapRows"),
|
||||
],
|
||||
&[("ROW_TYPE", "Row")],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--handlers") {
|
||||
compare(
|
||||
&core,
|
||||
"handler",
|
||||
"handler",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/handler.rs")),
|
||||
&[
|
||||
("GENERATED_INTEGER", "integerEntry"),
|
||||
("GENERATED_MAP", "mapEntry"),
|
||||
("GENERATED_FOLD", "foldEntry"),
|
||||
("GENERATED_TEXT", "textEntry"),
|
||||
("GENERATED_APPEND", "append"),
|
||||
("GENERATED_ROWS", "rowsEntry"),
|
||||
("GENERATED_CAPTURE", "captureEntry"),
|
||||
],
|
||||
&[
|
||||
("ROW_TYPE", "Row"),
|
||||
("RESULT_TYPE", "Result"),
|
||||
("PROBLEM_TYPE", "Problem"),
|
||||
],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if std::env::args().any(|argument| argument == "--list-audit") {
|
||||
compare(
|
||||
&core,
|
||||
"core",
|
||||
"list",
|
||||
include_str!("performance/list.rs"),
|
||||
&[("GENERATED_LIST", "total")],
|
||||
&[],
|
||||
);
|
||||
return;
|
||||
}
|
||||
if build::collections(&core) {
|
||||
return;
|
||||
}
|
||||
compare(
|
||||
&core,
|
||||
"core",
|
||||
"core",
|
||||
&(include_str!("performance/samples.rs").to_owned()
|
||||
+ include_str!("performance/reference.rs")),
|
||||
&[
|
||||
("GENERATED_INTEGER", "arithmetic"),
|
||||
("GENERATED_LIST", "total"),
|
||||
("GENERATED_TEXT", "join"),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
compare(
|
||||
&core,
|
||||
"choice",
|
||||
"choice",
|
||||
include_str!("performance/choice.rs"),
|
||||
&[
|
||||
("GENERATED_STATE", "readState"),
|
||||
("GENERATED_NULLABLE", "nullableText"),
|
||||
("GENERATED_PROPAGATE", "propagate"),
|
||||
("GENERATED_CAPTURE", "capture"),
|
||||
("GENERATED_CHANGE", "change"),
|
||||
],
|
||||
&[("STATE_TYPE", "State"), ("RESULT_TYPE", "Result")],
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user