MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / busyWriteTx

Function busyWriteTx

xenomint/sqlite/sqlite_test.go:829–871  ·  view source on GitHub ↗
(
	b *testing.B,
	wg *sync.WaitGroup, sc <-chan struct{},
	st xi.Storage, kg keygen, e string, src [][]interface{},
)

Source from the content-addressed store, hash-verified

827}
828
829func busyWriteTx(
830 b *testing.B,
831 wg *sync.WaitGroup, sc <-chan struct{},
832 st xi.Storage, kg keygen, e string, src [][]interface{},
833) {
834 defer wg.Done()
835 var (
836 tx *sql.Tx
837 err error
838 )
839 for i := 0; ; i++ {
840 // Begin
841 if i%benchmarkQueriesPerTx == 0 {
842 if tx, err = st.Writer().Begin(); err != nil {
843 b.Errorf("failed to begin transaction: %v", err)
844 }
845 }
846 // Exec
847 select {
848 case <-sc:
849 // Also commit on exiting
850 if tx != nil {
851 if err = tx.Commit(); err != nil {
852 b.Errorf("failed to commit transaction: %v", err)
853 }
854 tx = nil
855 }
856 return
857 default:
858 // Exec
859 if _, err = tx.Exec(e, src[kg.next()]...); err != nil {
860 b.Errorf("failed to execute: %v", err)
861 }
862 }
863 // Commit
864 if (i+1)%benchmarkQueriesPerTx == 0 {
865 if err = tx.Commit(); err != nil {
866 b.Errorf("failed to commit transaction: %v", err)
867 }
868 tx = nil
869 }
870 }
871}
872
873func idleWriteTx(
874 b *testing.B,

Callers 1

BenchmarkStorageFunction · 0.85

Calls 6

ErrorfMethod · 0.80
WriterMethod · 0.65
CommitMethod · 0.65
ExecMethod · 0.65
nextMethod · 0.65
BeginMethod · 0.45

Tested by

no test coverage detected