Permalink
Browse files

Results of reformatting using http4s scalafmt settings

  • Loading branch information...
mpilquist committed Jan 3, 2018
1 parent d9fb316 commit 7ad702a21e4af95e188cff9a7352ff3bc17beabd
Showing with 1,185 additions and 1,913 deletions.
  1. +2 −4 benchmark/src/main/scala/fs2/benchmark/ByteBufferChunkBenchmark.scala
  2. +17 −38 benchmark/src/main/scala/fs2/benchmark/StreamBenchmark.scala
  3. +9 −19 build.sbt
  4. +2 −4 core/js/src/main/scala/fs2/SchedulerPlatform.scala
  5. +12 −18 core/jvm/src/main/scala/fs2/SchedulerPlatform.scala
  6. +4 −4 core/jvm/src/main/scala/fs2/StreamApp.scala
  7. +15 −28 core/jvm/src/main/scala/fs2/compress.scala
  8. +6 −17 core/jvm/src/test/scala/fs2/CompressSpec.scala
  9. +1 −2 core/jvm/src/test/scala/fs2/EventuallySupport.scala
  10. +3 −4 core/jvm/src/test/scala/fs2/HashSpec.scala
  11. +3 −6 core/jvm/src/test/scala/fs2/MemorySanityChecks.scala
  12. +12 −16 core/jvm/src/test/scala/fs2/MergeJoinSpec.scala
  13. +29 −41 core/jvm/src/test/scala/fs2/Pipe2Spec.scala
  14. +30 −49 core/jvm/src/test/scala/fs2/PipeSpec.scala
  15. +56 −70 core/jvm/src/test/scala/fs2/ResourceSafetySpec.scala
  16. +3 −5 core/jvm/src/test/scala/fs2/SchedulerSpec.scala
  17. +4 −8 core/jvm/src/test/scala/fs2/StreamAppSpec.scala
  18. +13 −15 core/jvm/src/test/scala/fs2/StreamPerformanceSpec.scala
  19. +15 −27 core/jvm/src/test/scala/fs2/StreamSpec.scala
  20. +1 −2 core/jvm/src/test/scala/fs2/TestUtilPlatform.scala
  21. +24 −30 core/jvm/src/test/scala/fs2/async/QueueSpec.scala
  22. +11 −15 core/shared/src/main/scala/fs2/AsyncPull.scala
  23. +5 −10 core/shared/src/main/scala/fs2/Catenable.scala
  24. +19 −37 core/shared/src/main/scala/fs2/Chunk.scala
  25. +1 −3 core/shared/src/main/scala/fs2/CompositeFailure.scala
  26. +1 −2 core/shared/src/main/scala/fs2/Interrupted.scala
  27. +6 −12 core/shared/src/main/scala/fs2/Pipe.scala
  28. +6 −13 core/shared/src/main/scala/fs2/Pipe2.scala
  29. +17 −26 core/shared/src/main/scala/fs2/Pull.scala
  30. +33 −50 core/shared/src/main/scala/fs2/Scheduler.scala
  31. +112 −160 core/shared/src/main/scala/fs2/Segment.scala
  32. +241 −360 core/shared/src/main/scala/fs2/Stream.scala
  33. +10 −18 core/shared/src/main/scala/fs2/async/Promise.scala
  34. +1 −2 core/shared/src/main/scala/fs2/async/Ref.scala
  35. +16 −29 core/shared/src/main/scala/fs2/async/async.scala
  36. +1 −2 core/shared/src/main/scala/fs2/async/immutable/Signal.scala
  37. +41 −85 core/shared/src/main/scala/fs2/async/mutable/Queue.scala
  38. +8 −18 core/shared/src/main/scala/fs2/async/mutable/Semaphore.scala
  39. +5 −10 core/shared/src/main/scala/fs2/async/mutable/Signal.scala
  40. +3 −6 core/shared/src/main/scala/fs2/async/mutable/Topic.scala
  41. +1 −2 core/shared/src/main/scala/fs2/fs2.scala
  42. +34 −76 core/shared/src/main/scala/fs2/internal/Algebra.scala
  43. +47 −80 core/shared/src/main/scala/fs2/internal/CompileScope.scala
  44. +5 −7 core/shared/src/main/scala/fs2/internal/FreeC.scala
  45. +1 −3 core/shared/src/main/scala/fs2/internal/LinkedMap.scala
  46. +3 −7 core/shared/src/main/scala/fs2/internal/Resource.scala
  47. +14 −23 core/shared/src/main/scala/fs2/text.scala
  48. +16 −24 io/src/main/scala/fs2/io/JavaInputOutputStream.scala
  49. +8 −20 io/src/main/scala/fs2/io/file/FileHandle.scala
  50. +41 −76 io/src/main/scala/fs2/io/file/Watcher.scala
  51. +7 −13 io/src/main/scala/fs2/io/file/file.scala
  52. +16 −26 io/src/main/scala/fs2/io/file/pulls.scala
  53. +10 −23 io/src/main/scala/fs2/io/io.scala
  54. +38 −66 io/src/main/scala/fs2/io/tcp/Socket.scala
  55. +1 −6 io/src/main/scala/fs2/io/tcp/tcp.scala
  56. +19 −40 io/src/main/scala/fs2/io/udp/AsynchronousSocketGroup.scala
  57. +54 −59 io/src/main/scala/fs2/io/udp/Socket.scala
  58. +7 −19 io/src/main/scala/fs2/io/udp/udp.scala
  59. +2 −4 io/src/test/scala/fs2/io/JavaInputOutputStreamSpec.scala
  60. +5 −7 io/src/test/scala/fs2/io/file/WatcherSpec.scala
  61. +1 −2 io/src/test/scala/fs2/io/tcp/SocketSpec.scala
  62. +56 −63 io/src/test/scala/fs2/io/udp/UdpSpec.scala
  63. +1 −2 scodec/shared/src/main/scala/fs2/interop/scodec/ByteVectorChunk.scala
@@ -23,26 +23,24 @@ class ByteBufferChunkBenchmark {
Chunk.bytes(bbIndirect.array).toArray
@Benchmark
def bytesToArrayDirect(): Array[Byte] = {
def bytesToArrayDirect(): Array[Byte] =
Chunk.bytes {
val arr = new Array[Byte](bbDirect.remaining)
bbDirect.slice.get(arr, 0, bbDirect.remaining)
arr
}.toArray
}
@Benchmark
def bytesToByteBufferIndirect(): ByteBuffer =
Chunk.bytes(bbIndirect.array).toByteBuffer
@Benchmark
def bytesToByteBufferDirect(): ByteBuffer = {
def bytesToByteBufferDirect(): ByteBuffer =
Chunk.bytes {
val arr = new Array[Byte](bbDirect.remaining)
bbDirect.slice.get(arr, 0, bbDirect.remaining)
arr
}.toByteBuffer
}
@Benchmark
def byteBufferToArrayIndirect(): Array[Byte] =
@@ -2,23 +2,15 @@ package fs2
package benchmark
import cats.effect.IO
import org.openjdk.jmh.annotations.{
Benchmark,
BenchmarkMode,
Mode,
OutputTimeUnit,
Scope,
State
}
import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Mode, OutputTimeUnit, Scope, State}
import java.util.concurrent.TimeUnit
@State(Scope.Thread)
class StreamBenchmark {
@GenerateN(2, 3, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200,
102400)
@GenerateN(2, 3, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400)
@Benchmark
def leftAssocConcat(N: Int): Int = {
def leftAssocConcat(N: Int): Int =
(1 until N)
.map(Stream.emit)
.foldRight(Stream.empty.covaryOutput[Int])(_ ++ _)
@@ -27,12 +19,10 @@ class StreamBenchmark {
.last
.unsafeRunSync
.get
}
@GenerateN(2, 3, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200,
102400)
@GenerateN(2, 3, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400)
@Benchmark
def rightAssocConcat(N: Int): Int = {
def rightAssocConcat(N: Int): Int =
(0 until N)
.map(Stream.emit)
.foldRight(Stream.empty.covaryOutput[Int])(_ ++ _)
@@ -41,12 +31,10 @@ class StreamBenchmark {
.last
.unsafeRunSync
.get
}
@GenerateN(2, 3, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200,
102400)
@GenerateN(2, 3, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400)
@Benchmark
def leftAssocFlatMap(N: Int): Int = {
def leftAssocFlatMap(N: Int): Int =
(1 until N)
.map(Stream.emit)
.foldLeft(Stream.emit(0))((acc, a) => acc.flatMap(_ => a))
@@ -55,12 +43,10 @@ class StreamBenchmark {
.last
.unsafeRunSync
.get
}
@GenerateN(2, 3, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200,
102400)
@GenerateN(2, 3, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400)
@Benchmark
def rightAssocFlatMap(N: Int): Int = {
def rightAssocFlatMap(N: Int): Int =
(1 until N)
.map(Stream.emit)
.reverse
@@ -70,25 +56,21 @@ class StreamBenchmark {
.last
.unsafeRunSync
.get
}
@GenerateN(2, 3, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200,
102400)
@GenerateN(2, 3, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200, 102400)
@Benchmark
def eval(N: Int): Unit = {
def eval(N: Int): Unit =
Stream.repeatEval(IO(())).take(N).compile.last.unsafeRunSync.get
}
@GenerateN(0, 2, 3, 6, 12, 25, 50, 100, 200, 400, 800, 1600, 3200, 6400,
12800, 25600, 51200, 102400)
@GenerateN(0, 2, 3, 6, 12, 25, 50, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200,
102400)
@Benchmark
def toVector(N: Int): Vector[Int] = {
def toVector(N: Int): Vector[Int] =
Stream.emits(0 until N).covary[IO].compile.toVector.unsafeRunSync
}
@GenerateN(1, 2, 4, 8, 16, 32, 64, 128, 256)
@Benchmark
def unconsPull(N: Int): Int = {
def unconsPull(N: Int): Int =
(Stream
.chunk(Chunk.seq(0 to 256000)))
.repeatPull { s =>
@@ -102,12 +84,9 @@ class StreamBenchmark {
.last
.unsafeRunSync
.get
}
@GenerateN(1, 10, 100, 1000, 10000)
@Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(
TimeUnit.NANOSECONDS)
def emitsThenFlatMap(N: Int): Vector[Int] = {
@Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.NANOSECONDS)
def emitsThenFlatMap(N: Int): Vector[Int] =
Stream.emits(0 until N).flatMap(Stream(_)).toVector
}
}
View
@@ -52,9 +52,8 @@ lazy val commonSettings = Seq(
"org.scalacheck" %%% "scalacheck" % "1.13.5" % "test",
"org.typelevel" %%% "cats-laws" % "1.0.1" % "test"
),
scmInfo := Some(
ScmInfo(url("https://github.com/functional-streams-for-scala/fs2"),
"git@github.com:functional-streams-for-scala/fs2.git")),
scmInfo := Some(ScmInfo(url("https://github.com/functional-streams-for-scala/fs2"),
"git@github.com:functional-streams-for-scala/fs2.git")),
homepage := Some(url("https://github.com/functional-streams-for-scala/fs2")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
initialCommands := s"""
@@ -110,10 +109,7 @@ lazy val publishingSettings = Seq(
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield
Credentials("Sonatype Nexus Repository Manager",
"oss.sonatype.org",
username,
password)).toSeq,
Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq,
publishMavenStyle := true,
pomIncludeRepository := { _ =>
false
@@ -216,14 +212,12 @@ lazy val coreJVM = core.jvm
val Some((major, minor)) = CrossVersion.partialVersion(scalaVersion.value)
Seq(s"""scala.*;version="[$major.$minor,$major.${minor + 1})"""", "*")
},
OsgiKeys.additionalHeaders := Map(
"-removeheaders" -> "Include-Resource,Private-Package"),
OsgiKeys.additionalHeaders := Map("-removeheaders" -> "Include-Resource,Private-Package"),
osgiSettings,
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, minor)) if minor >= 13 =>
Seq(
"org.scala-lang.modules" %% "scala-parallel-collections" % "0.1.2" % "test")
Seq("org.scala-lang.modules" %% "scala-parallel-collections" % "0.1.2" % "test")
case _ =>
Seq()
}
@@ -247,8 +241,7 @@ lazy val io = project
"""fs2.*;version="${Bundle-Version}"""",
"*")
},
OsgiKeys.additionalHeaders := Map(
"-removeheaders" -> "Include-Resource,Private-Package"),
OsgiKeys.additionalHeaders := Map("-removeheaders" -> "Include-Resource,Private-Package"),
osgiSettings
)
.dependsOn(coreJVM % "compile->compile;test->test")
@@ -276,8 +269,7 @@ lazy val scodecJVM = scodec.jvm
"""fs2.*;version="${Bundle-Version}"""",
"*")
},
OsgiKeys.additionalHeaders := Map(
"-removeheaders" -> "Include-Resource,Private-Package"),
OsgiKeys.additionalHeaders := Map("-removeheaders" -> "Include-Resource,Private-Package"),
osgiSettings
)
lazy val scodecJS = scodec.js.disablePlugins(DoctestPlugin, MimaPlugin)
@@ -289,8 +281,7 @@ lazy val benchmarkMacros = project
.settings(noPublish)
.settings(
name := "fs2-benchmark-macros",
addCompilerPlugin(
"org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch),
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch),
libraryDependencies += scalaOrganization.value % "scala-reflect" % scalaVersion.value
)
@@ -303,8 +294,7 @@ lazy val benchmark = project
name := "fs2-benchmark"
)
.settings(
addCompilerPlugin(
"org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch),
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch),
libraryDependencies += scalaOrganization.value % "scala-reflect" % scalaVersion.value
)
.enablePlugins(JmhPlugin)
@@ -5,14 +5,12 @@ import scala.scalajs.js.timers._
private[fs2] trait SchedulerPlatform {
val default: Scheduler = new Scheduler {
override def scheduleOnce(delay: FiniteDuration)(
thunk: => Unit): () => Unit = {
override def scheduleOnce(delay: FiniteDuration)(thunk: => Unit): () => Unit = {
val handle = setTimeout(delay)(thunk)
() =>
{ clearTimeout(handle) }
}
override def scheduleAtFixedRate(period: FiniteDuration)(
thunk: => Unit): () => Unit = {
override def scheduleAtFixedRate(period: FiniteDuration)(thunk: => Unit): () => Unit = {
val handle = setInterval(period)(thunk)
() =>
{ clearInterval(handle) }
@@ -14,22 +14,20 @@ private[fs2] trait SchedulerPlatform {
def apply[F[_]](corePoolSize: Int,
daemon: Boolean = true,
threadPrefix: String = "fs2-scheduler",
exitJvmOnFatalError: Boolean = true)(
implicit F: Sync[F]): Stream[F, Scheduler] =
Stream.bracket(
allocate(corePoolSize, daemon, threadPrefix, exitJvmOnFatalError))(
exitJvmOnFatalError: Boolean = true)(implicit F: Sync[F]): Stream[F, Scheduler] =
Stream.bracket(allocate(corePoolSize, daemon, threadPrefix, exitJvmOnFatalError))(
t => Stream.emit(t._1),
_._2)
/**
* Allocates a scheduler in the specified effect type and returns the scheduler along with a shutdown
* task, that when executed, terminates the thread pool used by the scheduler.
*/
def allocate[F[_]](corePoolSize: Int,
daemon: Boolean = true,
threadPrefix: String = "fs2-scheduler",
exitJvmOnFatalError: Boolean = true)(
implicit F: Sync[F]): F[(Scheduler, F[Unit])] =
def allocate[F[_]](
corePoolSize: Int,
daemon: Boolean = true,
threadPrefix: String = "fs2-scheduler",
exitJvmOnFatalError: Boolean = true)(implicit F: Sync[F]): F[(Scheduler, F[Unit])] =
F.delay {
val executor = Executors.newScheduledThreadPool(
corePoolSize,
@@ -38,18 +36,14 @@ private[fs2] trait SchedulerPlatform {
}
/** Creates a scheduler from the specified executor service. */
def fromScheduledExecutorService(
service: ScheduledExecutorService): Scheduler = new Scheduler {
override def scheduleOnce(delay: FiniteDuration)(
thunk: => Unit): () => Unit = {
val f = service.schedule(new Runnable { def run = thunk },
delay.toNanos,
TimeUnit.NANOSECONDS)
def fromScheduledExecutorService(service: ScheduledExecutorService): Scheduler = new Scheduler {
override def scheduleOnce(delay: FiniteDuration)(thunk: => Unit): () => Unit = {
val f =
service.schedule(new Runnable { def run = thunk }, delay.toNanos, TimeUnit.NANOSECONDS)
() =>
{ f.cancel(false); () }
}
override def scheduleAtFixedRate(period: FiniteDuration)(
thunk: => Unit): () => Unit = {
override def scheduleAtFixedRate(period: FiniteDuration)(thunk: => Unit): () => Unit = {
val f = service.scheduleAtFixedRate(new Runnable { def run = thunk },
period.toNanos,
period.toNanos,
@@ -55,10 +55,10 @@ abstract class StreamApp[F[_]](implicit F: Effect[F]) {
* @param ec Implicit EC to run the application stream
* @return An IO that will produce an ExitCode
*/
private[fs2] def runStream(args: List[String],
exitCodePromise: Promise[IO, ExitCode],
halted: Signal[IO, Boolean])(
implicit ec: ExecutionContext): IO[ExitCode] =
private[fs2] def runStream(
args: List[String],
exitCodePromise: Promise[IO, ExitCode],
halted: Signal[IO, Boolean])(implicit ec: ExecutionContext): IO[ExitCode] =
async
.signalOf[F, Boolean](false)
.flatMap { requestShutdown =>
Oops, something went wrong.

0 comments on commit 7ad702a

Please sign in to comment.