This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Read all of the bytes in a mmaped file. Compile like: | |
| // gcc --std=gnu99 -g fault.c -o fault | |
| // Run like | |
| // ./fault path/to/big/file | |
| #include <assert.h> | |
| #include <stdio.h> | |
| #include <sys/mman.h> | |
| #include <unistd.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it was i. sorry. | |
| $ comes from 1,$p in earlier editors. | |
| . for the same reason. | |
| ^ is about the only unused character on the 33 teletype. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <string> | |
| #include <iterator> | |
| #include <iostream> | |
| #include <algorithm> | |
| #include <array> | |
| int main() | |
| { | |
| // construction uses aggregate initialization | |
| std::array<int, 3> a1{ {1,2,3} }; // double-braces required |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| evan@fedora ~/code/index (master) $ ./bin/print_ngram_counts /var/codesearch/ | head -n 100 | |
| distinct ngrams: 385054 | |
| total ngram count: 365009415 | |
| 1806890 0.495026% 0.495026% \x20=\x20 | |
| 1614139 0.442218% 0.937244% \x09\x09\x09 | |
| 1114430 0.305315% 1.242559% \x20\x20\x20 | |
| 1075092 0.294538% 1.537098% str | |
| 1072463 0.293818% 1.830916% \x20*/ | |
| 1027687 0.281551% 2.112466% \x20*\x20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| make -k -C .. | |
| make: Entering directory `/home/evan/code/index' | |
| make -C build | |
| make[1]: Entering directory `/home/evan/code/index/build' | |
| CXX(target) out/Default/obj.target/csearch/src/integer_index_reader.o | |
| In file included from ../src/./integer_index_reader.h:11:0, | |
| from ../src/integer_index_reader.cc:4: | |
| ../src/././sstable_reader.h: In member function ‘bool codesearch::SSTableReader::FindWithBounds(const char*, std::string*, std::size_t*) const’: | |
| ../src/././sstable_reader.h:233:15: error: no match for ‘operator!=’ in ‘lb != e’ | |
| ../src/././sstable_reader.h:233:15: note: candidate is: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /usr/include/boost/iterator/iterator_facade.hpp: In substitution of | |
| ‘template<class Derived1, | |
| class V1, | |
| class TC1, | |
| class Reference1, | |
| class Difference1, | |
| class Derived2, | |
| class V2, | |
| class TC2, | |
| class Reference2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| + 16.71% rpcserver [kernel.kallsyms] [k] _raw_spin_unlock_irqrestore | |
| + 11.61% rpcserver [kernel.kallsyms] [k] default_send_IPI_mask_sequence_phys | |
| + 11.31% rpcserver [kernel.kallsyms] [k] isolate_migratepages_range | |
| + 8.11% rpcserver [kernel.kallsyms] [k] mutex_spin_on_owner | |
| + 5.86% rpcserver rpcserver [.] codesearch::NGramIndexReader::TrimCandidates(std | |
| + 4.38% rpcserver [kernel.kallsyms] [k] native_flush_tlb_others | |
| + 2.75% rpcserver [kernel.kallsyms] [k] _raw_spin_lock | |
| + 2.65% rpcserver [kernel.kallsyms] [k] finish_task_switch | |
| + 1.87% rpcserver [kernel.kallsyms] [k] copy_page_c | |
| + 1.79% rpcserver [kernel.kallsyms] [k] rmap_walk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bool IsValidUtf8(const std::string &src) { | |
| int n = 0; | |
| for (const char &i : src) { | |
| int c = static_cast<int>(i) & 0xFF; | |
| if (n) { | |
| if ((c & 0xC0) != 0x80) { | |
| return false; | |
| } | |
| n--; | |
| continue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| evan@loonix ~/code/associative-benchmark $ ./bench -n 10000000 | |
| generating number list with 10000000 integer pairs... | |
| map | |
| ---------- | |
| create: 10695365 | |
| search: 10576007 | |
| hash | |
| ---------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name = 'Evan' | |
| def foo(): | |
| global name # correct | |
| name = 'Oven' | |
| def bar(): | |
| global name # incorrect | |
| print name |