Skip to content

Commit baf0bd7

Browse files
committed
AWS benches first step
1 parent 500152c commit baf0bd7

7 files changed

Lines changed: 70 additions & 0 deletions

File tree

benchmark/aws-sdk-go-v2/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module s3cpp_aws-sdk-go-v2
2+
3+
go 1.25.5

benchmark/aws-sdk-go-v2/main.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
/*
4+
#include <stdlib.h>
5+
*/
6+
import "C"
7+
import "unsafe"
8+
9+
// export get_object
10+
func get_object(key *C.char) *C.char {
11+
k := C.GoString(key)
12+
s := "Hello from Go! Key: " + k
13+
return C.CString(s)
14+
}
15+
16+
//export free_object
17+
func free_object(ptr *C.char) {
18+
C.free(unsafe.Pointer(ptr))
19+
}
20+
21+
func main() {}

benchmark/aws-sdk-rust/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benchmark/aws-sdk-rust/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "aws-sdk-rust"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]

benchmark/aws-sdk-rust/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use std::ffi::CString;
2+
3+
#[unsafe(no_mangle)]
4+
pub unsafe extern "C" fn get_object(key: *const std::ffi::c_char) -> *const std::ffi::c_char {
5+
let result = format!("Hello from Rust! Key: {:?}", key).to_string();
6+
let c_result = CString::new(result).expect("CString::new failed");
7+
c_result.as_ptr()
8+
}

benchmark/task.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "task.h"
2+
#include <format>
3+
#include <string>
4+
5+
extern "C" {
6+
const char* get_object(const char* key) noexcept {
7+
static std::string result;
8+
result = std::format("Hello from C++!\nKey: {}", key);
9+
return result.c_str();
10+
}
11+
}

benchmark/task.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef S3CPP_BENCHMARK_TASK_H
2+
#define S3CPP_BENCHMARK_TASK_H
3+
4+
namespace s3bench {
5+
6+
typedef const char* get_object_f(const char* key) noexcept;
7+
8+
extern "C"
9+
__attribute__((visibility("default")))
10+
get_object_f get_object;
11+
12+
} // namespace s3bench
13+
14+
#endif

0 commit comments

Comments
 (0)