Using the ASX data. SQL to create table and index is:
create table asx (company char(3), date date, open double precision, high double precision, low double precision, close double precision, volume double precision, adjclose double precision);
| amos@localhost option-test $ swiftc uint.swift && ./main | |
| 2^62 = 4611686018427387904 | |
| 2^63 - 1 = 9223372036854775807 | |
| Illegal instruction | |
| # Running with -Ounchecked gives wrong result.. (last two numbers are same) | |
| amos@localhost option-test $ swiftc tx1-uint.swift -Ounchecked && ./main | |
| 2^62 = 4611686018427387904 | |
| 2^63 - 1 = 9223372036854775807 | |
| 2^63 = 9223372036854775807 |
| 13> let y : UnsafeMutablePointer<UInt8> = unsafeDowncast(malloc(50)) | |
| repl.swift:13:39: error: generic parameter 'T' could not be inferred | |
| let y : UnsafeMutablePointer<UInt8> = unsafeDowncast(malloc(50)) | |
| ^ | |
| Swift.unsafeDowncast:12:13: note: in call to function 'unsafeDowncast' | |
| public func unsafeDowncast<T : AnyObject>(x: AnyObject) -> T | |
| ^ | |
| 13> let y : UnsafeMutablePointer<UInt8> = unsafeDowncast<UnsafeMutablePointer<UInt8>>(malloc(50)) | |
| repl.swift:13:39: error: cannot explicitly specialize a generic function |
| #include <x86intrin.h> | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| static const uint32_t powers_of_ten_multipliers[] | |
| = { 10000000, 1000000, 100000, 10000 | |
| , 1000 , 100 , 10 , 1 | |
| , 0 , 0 , 0 , 0 | |
| , 0 , 0 , 0 , 0 |
| #include <fcntl.h> | |
| #include <math.h> | |
| #include <stdbool.h> | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <sys/mman.h> | |
| #include <sys/param.h> | |
| #include <sys/stat.h> |
| ## $FILES is names of all files to be split | |
| ## splits files into two | |
| # find largest file | |
| largest=`ls $FILES -l | sort -k5 -nr | head -n1 | awk '{ print $9 }'` | |
| # count how many lines in it | |
| lines=`wc -l $largest` |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <time.h> | |
| typedef long long int uint64_t; | |
| int cmp8_mask (const char *as, const char* bs, uint64_t len) | |
| { | |
| uint64_t rem = len; | |
| while (rem > 8) { |
| /* | |
| attempt at writing a faster memcmp | |
| */ | |
| static iint_t INLINE memcmp8 (const char *as, const char* bs, iint_t len) | |
| { | |
| uint64_t *a = (uint64_t*)as; | |
| uint64_t *b = (uint64_t*)bs; | |
| while (len > 8) { | |
| if (*a != *b) { | |
| return 1; |
| int read_bool (char *p) | |
| { | |
| static const uint64_t true_mask = 0x00000000ffffffff; | |
| static const uint64_t true_bits = 0x0000000065757274; | |
| static const uint64_t false_mask = 0x000000ffffffffff; | |
| static const uint64_t false_bits = 0x00000065736c6166; | |
| static const uint64_t to_lower = 0x2020202020202020; | |
| uint64_t next8 = *(uint64_t *)p | to_lower; |
| $ ls -lah asx.psv | |
| -rw-r--r-- 1 amos staff 59G 13 Nov 18:07 asx.psv | |
| $ time grep -v EntryError asx.psv > /dev/null | |
| real 14m33.885s | |
| user 14m10.081s | |
| sys 0m22.390s |