How are logarithms programmed? [closed]

独自空忆成欢 提交于 2020-01-20 22:07:18
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . Are they just figured out using the same mechanism as a linear search or is the range narrowed down somehow, similar to a binary search. 回答1: The implementation of a function such as the natural logarithm in any

How can I programmatically find the CPU frequency with C

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-29 04:45:08
问题 I'm trying to find out if there is anyway to get an idea of the CPU frequency of the system my C code is running on. To clarify, I'm looking for an abstract solution, (one that will not be tied to a specific architecture or OS) which can give me an idea of the operating frequency of the computer that my code is executing on. I don't need to be exact, but I'd like to be in the ball park (ie. I have a 2.2GHz processor, I'd like to be able to tell in my program that I'm within a few hundred MHz

retrieving cpu speed and remove } from output

蹲街弑〆低调 提交于 2019-12-24 12:33:56
问题 I'm trying to get cpu speed. This is what I've done so far $cpu = [string](get-wmiobject Win32_Processor | select name) $($cpu.split("@")[-1]).trim() and my output is 2.40GHz} How can I remove "}" from my output without having to play with string functions? Is there a better way to achieve my goal? Thanks in advance 回答1: PS > $p = Get-WmiObject Win32_Processor | Select-Object -ExpandProperty Name PS > $p -replace '^.+@\s' 2.40GHz 回答2: You know what ... I'am Unhappy ! Powershell gives objects

bogoMIPS value is changing

拈花ヽ惹草 提交于 2019-12-21 20:48:07
问题 I have been reading the cpuinfo file on my Samsung Galaxy (sgh-i897) to retrive the bogoMIPS value. And just now learning how to interpret such information. Initially I did this under the main activity in a loading thread, and ALWAYS got a value of 997.59. I then moved the file reading method into a Service since I didn't need it in the UI until much later anyways. Once I did this, the value I read became quite different, and seems to change for each application start, always much slower,

How to Disable Dynamic Frequency Scaling?

萝らか妹 提交于 2019-12-19 04:05:12
问题 I would like to do some microbenchmarks, and try to do them right. Unfortunately dynamic frequency scaling makes benchmarking highly unreliable. Is there a way to programmatically (C++, Windows) find out if dynamic frequency scaling is enabled? If, can this be disabled in a program? Ive tried to just use a warmup phase that uses 100% CPU for a second before the actual benchmark takes place, but this turned out to be not reliable either. UPDATE : Even when I disable SpeedStep in the BIOS, cpu

Does multi-threading improve performance? How?

自古美人都是妖i 提交于 2019-12-17 12:11:08
问题 I hear everyone talking about how multi-threading can improve performance. I don't believe this, unless there is something I'm missing. If I have an array of 100 elements and traversing it takes 6 seconds. When I divide the work between two threads, the processor would have to go through the same amount of work and therefore time, except that they are working simultaneously but at half the speed. Shouldn't multi threading make it even slower? Since you need additional instructions for

Machine code alignment

三世轮回 提交于 2019-12-12 08:55:11
问题 I am trying to understand the principles of machine code alignment. I have an assembler implementation which can generate machine code in run-time. I use 16-bytes alignment on every branch destination, but looks like it is not the optimal choice, since I've noticed that if I remove alignment than sometimes same code works faster. I think that something to do with cache line width, so that some commands are cut by a cache line and CPU experiences stalls because of that. So if some bytes of

Exactly how “fast” are modern CPUs?

夙愿已清 提交于 2019-12-12 07:08:42
问题 When I used to program embedded systems and early 8/16-bit PCs (6502, 68K, 8086) I had a pretty good handle on exacly how long (in nanoseconds or microseconds) each instruction took to execute. Depending on family, one (or four) cycles equated to one "memory fetch", and without caches to worry about, you could guess timings based on the number of memory accesses involved. But with modern CPU's, I'm confused. I know they're a lot faster, but I also know that the headline gigahertz speed isn't

How to calculate and print clock_t time roughly

偶尔善良 提交于 2019-12-11 13:36:15
问题 I am timing how long it takes to do three different types of searches, sequential, recursive binary, and iterative binary. I have those in place, and it does iterate through and finish the search. My problem is that when I time them all, I get 0 for all of them every time, even if I make an array of 100,000, and I have it search for something not in the array. If I set a break point in the search it obviously makes the time longer, and it gives me a reasonable time that I can work with. But

Animation speed on different devices

☆樱花仙子☆ 提交于 2019-12-10 00:40:48
问题 I have a simple translation animation in an Android game I am developing. When I test it on several devices, it runs at very different speeds on 10-inch tablets, 7-inch tablets and smartphones. What is the "state of the art" way of getting a uniform animation speed on different devices? Thanks, 回答1: I finally decided to use display.metrics to get the pixel density of the devices. Then I adjust the translation motion speed by dividing by the density value. Still wondering if this is the "state