Skip to content

Instantly share code, notes, and snippets.

View samueleresca's full-sized avatar

Samuele Resca samueleresca

View GitHub Profile
use cache_size::l1_cache_line_size;
/// Returns the result of a matrix multiplication.
/// Uses loop tiling to optimize the matrix multiplication.
/// The function relies on cache_size crate to get the cache line size.
///
/// # Arguments
///
/// * `n` - The dimension of the matrix.
pub fn optimized_tiled(n: usize) -> Vec<Vec<f64>> {
/// # Arguments
///
/// * `n` - The dimension of the matrix.
///
/// # Returns a matrix with values from 0 to n - 1.
/// Initializes a matrix with values from 0 to n - 1.
pub fn generate_matrix(n: usize) -> Vec<Vec<f64>> {
let mut matrix = vec![vec![0.0; n]; n];
let mut value = 0.0;
for r in 0..n {
/// Returns the result of the matrix multiplication.
///
/// # Arguments
///
/// * `n` - The dimension of the matrix.
pub fn non_optimized(n: usize) -> Vec<Vec<f64>> {
let m1 = generate_matrix(n);
let m2 = m1.clone();
let mut res = vec![vec![0.0; n]; n];
/// Returns an initialized matrix. The matrix is initialized in a standard way.
///
/// # Arguments
///
/// * `n` - The dimension of the matrix.
pub fn standard_initialize(n: usize) -> Vec<Vec<i32>> {
let mut data = vec![vec![0i32; n]; n];
for r in 0..n {
for c in 0..n {
#include "examples/libfuzzer/libfuzzer_example.pb.h"
#include "port/protobuf.h"
#include "src/libfuzzer/libfuzzer_macro.h"
protobuf_mutator::protobuf::LogSilencer log_silincer;
// ...
// This is the fuzz target
DEFINE_BINARY_PROTO_FUZZER(const libfuzzer_example::Msg& message) {
syntax = "proto2";
package libfuzzer_example;
import "google/protobuf/any.proto";
message Msg {
optional float optional_float = 1;
optional uint64 optional_uint64 = 2;
optional string optional_string = 3;
optional google.protobuf.Any any = 4;
// fuzz_target_http.cc
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
// Send HTTP request to the container
SendFuzzedPayload(Data, Size);
return 0;
}
// fuzz_target.cc
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
SystemUnderTest(Data, Size);
return 0;
}
package v3rpc
import (
"context"
"testing"
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
txn "go.etcd.io/etcd/server/v3/etcdserver/txn"
"go.etcd.io/etcd/server/v3/lease"
betesting "go.etcd.io/etcd/server/v3/storage/backend/testing"
//Strategy defines a strategy related to a QuorumSystem.
type Strategy struct {
Qs QuorumSystem
SigmaR Sigma
SigmaW Sigma
nodeToReadProbability map[Node]Probability
nodeToWriteProbability map[Node]Probability
}
// Sigma defines the probabilities of a specific Strategy. Each Expr (quorum) has a probability of being choose associated.