Search Results

Search found 4 results on 1 pages for 'wenlong'.

Page 1/1 | 1 

  • Why is writeSTRef faster than if expression?

    - by wenlong
    writeSTRef twice for each iteration fib3 :: Int -> Integer fib3 n = runST $ do a <- newSTRef 1 b <- newSTRef 1 replicateM_ (n-1) $ do !a' <- readSTRef a !b' <- readSTRef b writeSTRef a b' writeSTRef b $! a'+b' readSTRef b writeSTRef once for each iteration fib4 :: Int -> Integer fib4 n = runST $ do a <- newSTRef 1 b <- newSTRef 1 replicateM_ (n-1) $ do !a' <- readSTRef a !b' <- readSTRef b if a' > b' then writeSTRef b $! a'+b' else writeSTRef a $! a'+b' a'' <- readSTRef a b'' <- readSTRef b if a'' > b'' then return a'' else return b'' Benchmark, given n = 20000: benchmarking 20000/fib3 mean: 5.073608 ms, lb 5.071842 ms, ub 5.075466 ms, ci 0.950 std dev: 9.284321 us, lb 8.119454 us, ub 10.78107 us, ci 0.950 benchmarking 20000/fib4 mean: 5.384010 ms, lb 5.381876 ms, ub 5.386099 ms, ci 0.950 std dev: 10.85245 us, lb 9.510215 us, ub 12.65554 us, ci 0.950 fib3 is a bit faster than fib4.

    Read the article

  • Cannot access host from a virtualbox guest using bridged adapter

    - by David Dai
    I have a windows 7 host with firewall turned off. And I have a windowsXP guest running on Virtualbox 4.2.4r81684. In my windowsXP guest I tried to connect to the FTP server on my host machine(which used to work well) but it didn't work. I tried to ping my host machine, but it didn't work either. Then I tried to ping my guest from host, it worked well. my guest ip is :192.168.1.95 my host ip is : 192.168.1.9 route table on guest machine is this: C:\Documents and Settings\wenlong>route PRINT =========================================================================== Interface List 0x1 ........................... MS TCP Loopback interface 0x2 ...08 00 27 66 54 6c ...... AMD PCNET Family PCI Ethernet Adapter #2 - Packe t Scheduler Miniport =========================================================================== =========================================================================== Active Routes: Network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.95 20 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1 192.168.1.0 255.255.255.0 192.168.1.95 192.168.1.95 20 192.168.1.95 255.255.255.255 127.0.0.1 127.0.0.1 20 192.168.1.255 255.255.255.255 192.168.1.95 192.168.1.95 20 224.0.0.0 240.0.0.0 192.168.1.95 192.168.1.95 20 255.255.255.255 255.255.255.255 192.168.1.95 192.168.1.95 1 Default Gateway: 192.168.1.1 =========================================================================== Persistent Routes: None arp cache is this: C:\Documents and Settings\wenlong>arp -a Interface: 192.168.1.95 --- 0x2 Internet Address Physical Address Type 192.168.1.1 00-26-f2-60-3c-04 dynamic 192.168.1.9 90-e6-ba-c2-90-2f dynamic It's strange because there was no problem days before and I didn't make any changes to the setting. could anybody help? PS. the guest can communicate with other machines in the LAN(for example 192.168.1.114) ok. it just cannot connect to the host machine.

    Read the article

  • Performance Hosting under WAS vs Host as Service?

    - by ashraf
    I have some performance issue when I host WCF service (net.tcp) under WAS (IIS 7). It is working fine when I host service under console application. The issue is WCF Become Slow After Being Idle For 15 Seconds and a solution. After applying Wenlong Dong workaround delay is gone, but it does not work in WAS (IIS 7). I tried to put "ThreadPoolTimeoutWorkaround.DoWorkaround()" in static AppInitialize() as suggested here, still no luck. Thanks

    Read the article

  • WCF ChannelFactory caching

    - by Myles J
    I've just read this great article on WCF ChannelFactory caching by Wenlong Dong. My question is simply how can you actually prove that the ChannelFactory is in fact being cached between calls? I've followed the rules regarding the ClientBase’s constructors. We are using the following overloaded constructor on our object that inherits from ClientBase: ClientBase(string endpointConfigurationName, EndpointAddress remoteAddress); In the article mentioned above it is stated that: For these constructors, all arguments (including default ones) are in the following list: · InstanceContext callbackInstance · string endpointConfigurationName · EndpointAddress remoteAddress As long as these three arguments are the same when ClientBase is constructed, we can safely assume that the same ChannelFactory can be used. Fortunately, String and EndpointAddress types are immutable, i.e., we can make simple comparison to determine whether two arguments are the same. For InstanceContext, we can use Object reference comparison. The type EndpointTrait is thus used as the key of the MRU cache. To test the ChannelFactory cache theory we are checking the Hashcode in the ClientBase constructor e.g. var testHash = RuntimeHelpers.GetHashCode(base.ChannelFactory); The hash value is different between calls which makes us think that the ChannelFactory isn't actually cached. Any thoughts? Regards Myles

    Read the article

1