Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/07/2010 in all areas

  1. I think guaranteeing no corruption is a rather subtle. On SQLite's How to corrupt your database. the first possible problem beyond the uncontrollable is the OS/Filesystem not fsyncing properly. The next is ext3 (a journaled file system) without the barrier=1 option (which to my understanding breaks sync with write caching). I think the problem (there could be more) is that writes to the hard drive can be reordered ( which I I think can happen when write caching and NCQ don't properly fsync, also an active sqlite database journal normally two files). You might be able to work it without a write cache on a journaled file system, or by modifify SQLite3 to use a transactional interface to the underlining filesystem (I think reiser supported something like that). Anyway I would suggest keeping sync full or at least normal,since it's easy for someone to pragma anyway the safety. The sqlite doc recommend normal for mac since on OSX it works around lying IDE controllers by resetting, which really slows things down. The problem with committing on every query is that you can't compose multiple query's. Which is something I do since I want the database to always be consistent, and a lot of my operations involve reading something from the database and writing something that depends on what I just read, Instead of reopening the file by default you could wrap all query's in a uniquely named savepoint that you rollback to at the end of the query. Then you have the same level of safety with composability, and you gain performance from not having to reopen the database file. The only trick is to have separate begin transaction and rollback vi's (since those can't be wrapped in save points), which I'd recommend as a utility functions anyway (those are among the main VI's in my library). I think I figured it, my work computer is winxp and has write cache enabled which breaks fsync to some extent (I think). Now I see a difference on my WIn7 home computer which uses supports write cache buffer flushing (a proper fsync). Now I may need to get an additional hard drive at work just to run my database on if I want to guarantee (as best as possible) no database corruption. I think the difference between a Blank DB and :memory: db is that the blank is a data base with sync=0 and journal_mode=memory (the pragma's don't indicate this though), while with :memory: all the data in the database is stored in memory (as opposed to just the journal). On my home computer with my code on Win7 LV 2010 64bit all averages of 100 runs with my code. Full Sync: Insert 123.79 Dump 34.18 Normal Sync: Insert 104.02 Dump 34.24 No Sync: Insert 41.15 Dump 36.39 Full Sync memory journal: Insert 85.44 Dump 36.69 No Sync memory journal: Insert 82.59 Dump 36.54 No Sync memory journal: Insert 39.72 Dump 36.28 Normal Settings Blank file Insert 40.17 Dump 36.45 Normal Settings :memory: Insert 38.23 Dump 36.50 Your 1.1 speed test (averaged over 100 times) with sync modification hacked in Full sync Insert 444.65 Dump 75.86 Normal sync Insert 424.96 Dump 75.49 No Sync Insert 362.09 Dump 76
    1 point
  2. Phase of a sine wave wraps every 360 degrees, or 2*PI radian. Some markers: You'll get the initial slope of the sine wave to be negative for any values in the interval ]90, 270[ and positive in the intervals ]0, 90[ & ]270, 360[. 90 and 270 degrees will give an initial slope of zero (cosine and -cosine). 0 and 180 degrees will give an initial slope of 1*amplitude (sine and -sine) Some theory: The sine wave you're generating is of the form: y(t) = A * sin(w*t+ phi) + offset where A is the maximum amplitude w is the angular frequency and is also equal to 2*PI*frequency. Phi is phase in radian. If I understand your question correctly, you'd like to be able to calculate the phase necessary to generate a wave that starts at an amplitude of 60 and specify the initial slope. You want an initial amplitude of 60, so you know that y(t=0) = 60 and your max amplitude is 100. The equation is simple at t=0 => 60 = 100*sin(phi) or Phi = arcsin(60/100) = 0.6435 rad To get it in degrees, divide by PI and multiply by 180. ==> 36.87 deg Your solution will be slightly changed if your offset is not zero... Sine Phase.vi
    1 point
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.