THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.
PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!
THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.
PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| namespace Voron.Util | |
| { | |
| /// <summary> | |
| /// A list that can be used by readers as a true immutable read-only list | |
| /// and that supports relatively efficient "append to the end" and "remove | |
| /// from the front" operations, by sharing the underlying array whenever |
| public abstract class ConfigurationElementCollection<TKey, TElement> | |
| : ConfigurationElementCollection, | |
| IList<TElement>, IDictionary<TKey, TElement> | |
| where TElement : ConfigurationElement, new() | |
| { | |
| protected override ConfigurationElement CreateNewElement() | |
| { | |
| return new TElement(); | |
| } |
Original link: http://www.concentric.net/~Ttwang/tech/inthash.htm
Taken from: http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
Reformatted using pandoc
Thomas Wang, Jan 1997
last update Mar 2007
You can break these rules if you can talk your pair into agreeing with you.
| case class ListFoldRightBenchmark() extends SimpleScalaBenchmark { | |
| import scala.collection.mutable.ArrayStack | |
| @Param(Array("0", "1", "2", "3", "5", "10", "100", "500", "1000", "2000")) | |
| val length: Int = 0 | |
| var list: List[Int] = _ | |
| override def setUp() { | |
| // set up all your benchmark data here |
| #import <pthread.h> | |
| #import <mach/thread_act.h> | |
| // These two functions are declared in mach/thread_policy.h, but are commented out. | |
| // They are documented here: https://developer.apple.com/library/mac/#releasenotes/Performance/RN-AffinityAPI/_index.html | |
| kern_return_t thread_policy_set( | |
| thread_t thread, | |
| thread_policy_flavor_t flavor, | |
| thread_policy_t policy_info, | |
| mach_msg_type_number_t count); |
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
| using System; | |
| using System.Collections.Generic; | |
| using System.IO; | |
| using System.Linq; | |
| using System.Text; | |
| namespace SuffixTreeAlgorithm | |
| { | |
| public class SuffixTree | |
| { |
| // float->half variants. | |
| // by Fabian "ryg" Giesen. | |
| // | |
| // I hereby place this code in the public domain, as per the terms of the | |
| // CC0 license: | |
| // | |
| // https://creativecommons.org/publicdomain/zero/1.0/ | |
| // | |
| // float_to_half_full: This is basically the ISPC stdlib code, except | |
| // I preserve the sign of NaNs (any good reason not to?) |