Skip to content

Instantly share code, notes, and snippets.

@joaqo
joaqo / equal_to_c_speed_test.swift
Last active May 18, 2020 20:00
Changing the two commented lines in the code to the version used in this scripts makes this run twice as fast and makes it reach equal to C speed.
// Test motivated by the following discussion: https://twitter.com/vojtamolda/status/1258516339402006528
// Compile script: swiftc -O equal_to_c_speed_test.swift
import Foundation
// var result = ContiguousArray<Int>(repeating: 0, count: 3001)
var result = [Int](repeating: 0, count: 3001)
for it in 0..<15 {
let start = Date()
result.withUnsafeMutableBufferPointer { buffer in
deepbern ~/swift-models tensorflow-0.8 * > swift run Personlab
warning: you may be able to install libv4l-dev using your system-packager:
apt-get install libv4l-dev
warning: you may be able to install freeglut3-dev using your system-packager:
apt-get install freeglut3-dev
warning: you may be able to install mesa-commmon-dev using your system-packager:
apt-get install mesa-common-dev
~ > /Library/Developer/Toolchains/swift-tensorflow-RELEASE-0.7.xctoolchain/usr/bin/swift
Welcome to Swift version 5.2-dev.
Type :help for assistance.
1> import TensorFlow
2> let a = Tensor<Int32>(shape: TensorShape([2]), scalars: [0, 1])
*** DESERIALIZATION FAILURE (please include this section in any bug report) ***
could not deserialize type for '_cDataType': top-level value not found
Cross-reference to module 'CTensorFlow'
... TF_DataType
@joaqo
joaqo / sumlist.c
Created March 10, 2020 21:41
Just a silly short list sum script to provide as a baseline for benchmarking Swift code.
// clang -O3 -march=native deleteme.c -o del_c
#include <stdio.h>
#include <time.h>
int main () {
clock_t start, end;
double cpu_time_used;
int n[ 3000 ];